Operations 34 min read

Essential Linux Interview Q&A: From GPL Basics to System Optimization

This article provides concise answers to common Linux interview questions, covering GPL and free software concepts, distro selection, essential startup services, system optimization steps, runlevels, boot process, link types, partition planning, file deletion, vi usage, user management commands, grep and sed options, crontab syntax, important directories, shutdown/reboot commands, sudoers configuration, permission management, SecureCRT shortcuts, log auditing solutions, network troubleshooting, shell quoting, startup configuration files, and a list of useful Linux commands.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Essential Linux Interview Q&A: From GPL Basics to System Optimization

1. Explain what GPL, GNU, and free software are.

GPL (General Public License) is a license that grants anyone the right to obtain, modify, and redistribute free software.

GNU (GNU's Not Unix) aims to create a completely free and open operating system.

Free software can be used, copied, studied, modified, and distributed without restriction; the main licenses are GPL and BSD.

2. How to choose a Linux distribution?

Desktop users typically prefer Ubuntu; server users often choose RHEL or CentOS, with CentOS being the most common.

Specific requirements:

High security: choose Debian or FreeBSD.

Advanced database and mail services: choose SUSE.

New features: choose Fedora (a testing/pre‑release version of RHEL/CentOS).

Most internet companies use CentOS (commonly the 6.x series) for its server focus and lack of licensing constraints.

3. Which startup services should beginners enable on a Linux system?

Recommended services: crond: periodic task scheduler, essential for production. iptables: packet‑filter firewall, enable when an external IP is present. network: manage network interfaces at boot. sshd: remote login service, must be enabled for SSH access. rsyslog: system logging daemon (named syslog in older CentOS versions). sysstat: performance monitoring tools (CPU, disk, network throughput).

4. Describe the 12 steps for Linux system optimization.

Log in as a non‑root user; use sudo for privileged actions.

Disable root SSH login.

Synchronize system time automatically.

Configure yum repositories with domestic mirrors.

Disable SELinux and, when appropriate, iptables.

Increase the number of file descriptors.

Schedule automatic cleanup of /var/spool/clientmqueue to prevent disk exhaustion.

Trim unnecessary startup services (e.g., crond, sshd, network, rsyslog).

Optimize kernel parameters via /etc/sysctl.conf and apply with sysctl -p.

Set the system locale to English to avoid character‑set issues.

Lock critical system files with chattr +i (e.g., /etc/passwd, /etc/shadow, /etc/group, /etc/gshadow, /etc/inittab).

Clear /etc/issue to remove version information from the login screen.

5. Explain Linux runlevels 0‑6.

0 – Halt (shutdown).

1 – Single‑user mode (useful for password recovery).

2 – Multi‑user mode without networking.

3 – Multi‑user mode with networking (text mode, most common).

4 – Reserved (unused).

5 – Multi‑user mode with X‑Windows (graphical desktop).

6 – Reboot.

6. Outline the boot process from power‑on to login screen.

BIOS POST and load from disk.

Read MBR and start bootloader.

GRUB menu (boot loader) appears.

Load the Linux kernel.

Start init process, which reads /etc/inittab to set the runlevel. init executes rc.sysinit.

Kernel modules and runlevel‑specific scripts are executed.

Run /etc/rc.d/rc.local.

Start mingetty to present the login prompt.

7. Differentiate hard links and symbolic (soft) links.

Without options, ln creates a hard link; with -s it creates a symbolic link.

Hard links share the same inode as the source file; symbolic links have a different inode.

Hard links cannot be created for directories; symbolic links can point to directories.

Removing a symbolic link does not affect the source file or its hard links.

Removing a hard link does not affect the source file or other hard links.

Deleting the source file invalidates its symbolic links but leaves hard links intact.

Only when both the source file and all its hard links are removed is the data actually freed.

Snapshots often rely on hard‑link‑like mechanisms.

Symbolic links can cross filesystem boundaries; hard links cannot.

8. How to plan partitions for production Linux servers?

General principle: keep it simple, easy to manage, and suitable for batch operations. Suggested layouts per role:

Standalone server (e.g., 8 GB RAM, 300 GB disk) : /boot 100‑200 MB, swap 16 GB (2× RAM), / 80 GB, optional /var 20 GB, /data 180 GB for web/DB data. Use RAID 5 for balanced performance and redundancy.

Load balancer (e.g., LVS) : /boot 100‑200 MB, swap 1‑2× RAM, minimal other partitions. RAID 1 is sufficient.

RS server behind a load balancer : similar to load balancer layout; RAID 0 can be used when performance outweighs data safety.

Database server (MySQL/Oracle, 16‑32 GB RAM) : /boot 100‑200 MB, swap 16 GB, / 100 GB, /data for database files. RAID 10/RAID 5 for primary, RAID 0 for replicas.

Storage server : /boot 100‑200 MB, swap 1‑2× RAM, / 100 GB, /data for stored files. RAID 5 is typical.

Shared‑storage (NFS) server : similar to storage server; RAID 5, RAID 10, or RAID 0 depending on availability requirements.

Monitoring server (cacti, nagios) : /boot 100‑200 MB, swap 1‑2× RAM, minimal other partitions. RAID 1 or single disk is acceptable.

9. Explain the principle behind file deletion in Linux.

Linux tracks the link count of an inode. A file is physically removed only when its link count reaches zero and no process holds it open (i_count = 0, i_nlink = 0).

10. Briefly describe how to use the vi editor.

Three modes: normal, insert, and command.

In normal mode, keys are interpreted as commands (navigation, copy, paste, delete).

Insert mode ( i) allows text entry.

Command mode (accessed by :) executes commands such as wq (write & quit) or x. Prefix with ! to force.

11. Common user‑group management commands and their purposes.

Group commands: groupadd, groupdel, groupmod, groups, grpck, grpconv, grpunconv.

User commands: useradd, adduser, passwd, usermod, pwcov, pwck, pwunconv, finger, id, chfn, su.

12. Advanced grep options. -v: invert match. -e: use extended regex. -i: ignore case. -o: output only matching part. --color=auto: highlight matches. -n: show line numbers.

Special regex notes: ^word (starts with), word$ (ends with), ^$ (empty line), . (any single character), " (escape), * (zero or more), .* (any string), character classes [abc], negated classes [^abc], quantifiers {n,m}.

13. Advanced sed options. -n: suppress automatic printing. -p: print pattern space. -d: delete. -e: multiple editing commands.

Use

to reference captured groups (up to 9).

14. Commands to view currently logged‑in users. w, who, last, lastlog, whoami, finger, id.

15. Crontab purpose, syntax, and best practices.

Crontab schedules commands or scripts at fixed intervals. Syntax: minute hour day month weekday command. Use comments, place commands in scripts, specify full paths, prepend /bin/sh when needed, redirect output to /dev/null, and be careful with ,, -, and / operators.

16. Important Linux directories and their contents. /usr: user programs, libraries, documentation. /var: variable data (logs, spools, caches). /home: user home directories. /proc: virtual filesystem exposing kernel info. /bin, /sbin: essential binaries (user vs. superuser). /etc: system configuration files. /root: root's home. /dev: device files. /lib: shared libraries. /boot: bootloader and kernel images. /opt: optional software. /tmp: temporary files. /lost+found: recovered files. /media, /cd-rom: mount points for removable media.

17. Correct commands to shut down and reboot a server.

shutdown [-t time] [-r] [-k] [-h] [time]
halt

(equivalent to shutdown -h). reboot (similar to shutdown -r). init 0 (halt) and init 6 (reboot).

18. Important considerations when editing /etc/sudoers .

Alias names must be uppercase letters, digits, or underscores.

Multiple members are comma‑separated; members must exist.

Group aliases start with %; command aliases require absolute paths.

Use parentheses for run‑as specifications; ALL denotes any user.

Prefer full command paths.

Long lines can be continued with a backslash ( \).

Avoid granting ALL first; use the principle of least privilege.

Use NOPASSWD for password‑less execution when needed.

Prefix disallowed commands with ! after the allow list.

19. How to implement fine‑grained permission management in Linux?

Collect and define user‑role mappings, applying the principle of least privilege.

Assign permissions per group, down to individual commands.

Create appropriate groups and edit /etc/sudoers accordingly.

Grant sudo rights selectively, deciding whether a password is required.

Prefer whitelist approaches over broad ALL grants.

Test configurations thoroughly.

Document procedures and caveats.

Communicate changes to all stakeholders.

20. Functions of common SecureCRT shortcut keys.

Ctrl + a – move cursor to line start.

Ctrl + c – interrupt current program.

Ctrl + d – exit current session or logout.

Ctrl + e – move cursor to line end.

Ctrl + l – clear screen (like clear).

Ctrl + u – delete text before cursor.

Ctrl + k – delete text after cursor.

Ctrl + r – search command history.

Tab – autocomplete paths/commands.

Ctrl + Shift + c – copy.

Ctrl + Shift + v – paste.

Ctrl + q – cancel screen lock.

Ctrl + s – enable screen lock.

21. Five solutions for server account log auditing.

Audit all logs via syslog environment variables (high volume, not recommended).

Combine sudo with syslog to capture privileged command usage.

Wrap the Bash interpreter with a monitoring wrapper for all users.

Deploy a commercial bastion host (e.g., FortiGate).

22. Steps to troubleshoot a workstation that cannot access the Internet.

Verify physical link connectivity.

Check IP, routing, and DNS configuration.

Use telnet to test web service availability and firewall rules.

Ping the default gateway.

Ping successive routers toward the Internet.

Ping a known external IP address.

Test DNS resolution (ping a hostname).

If still unresolved, investigate upstream network equipment.

23. Difference between single quotes, double quotes, and no quotes in a shell.

Single quotes: literal string, no expansion.

Double quotes: allow variable and command substitution.

No quotes: words are split on whitespace; expansions occur, but special characters may cause parsing issues.

24. Important configuration files executed during Linux startup.

Typical order (Debian‑style):

/etc/environment → /etc/profile → (~/.bash_profile | ~/.bash_login | ~/.profile) → ~/.bashrc → /etc/bashrc → ~/.bash_logout

. Each file sets environment variables, runs scripts, or performs cleanup.

25. Purpose of the following paths. /var/log/messages – system log. /var/log/secure – security/authentication log. /var/spool/clientmqueue – mail queue for routine tasks. /proc/interrupts – current interrupt statistics. /etc/fstab – filesystem mount configuration. /etc/profile – global environment variables.

26. Commands to obtain eth0 IP and broadcast address using cut , awk , grep , or sed .

Examples include:

Using ifconfig eth0 | grep 'inet ' | cut -d' ' -f2 for the IP.

Using ifconfig eth0 | grep 'inet ' | awk '{print $2}' for the IP.

Using ifconfig eth0 | grep 'Bcast' | awk -F'[: ]+' '{print $4}' for the broadcast address.

Various sed pipelines to extract the same fields.

27. List of 20 useful Linux commands and their functions. cp – copy files/directories. mv – move/rename. mkdir – create directories. touch – create empty files. cd – change directory. cat – display file contents. ls – list directory contents. rm – remove files/directories. find – search for files. alias / unalias – manage command aliases. seq – generate sequences. head / tail – view beginning/end of files. sed – stream editor for text transformations. pwd – print working directory. rmdir – remove empty directories. echo – display a line of text. xargs – build and execute command lines from input. tree – display directory tree. rpm – query/install RPM packages. uname – display system information.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ShellNetworkingSystem Administration
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.