Top Linux Interview Questions: GPL, Buffers, Runlevels, Boot Process and More
This article provides concise explanations and command examples for common Linux interview topics, covering GPL and free software, buffer vs cache, runlevels, boot sequence, link types, shell exit status, history timestamps, log analysis, port forwarding, load troubleshooting, fstab fields, packaging, password generation, TCP state, and MySQL root recovery.
1. What are GPL, GNU, and free software?
GPL: (General Public License) – a license that grants anyone the right to obtain, modify, and redistribute free software.
GNU: (GNU Project) – aims to create a completely free and open operating system.
Free software: software that can be freely used, copied, studied, modified, and distributed without restriction. The main licenses are GPL and BSD.2. How are buffer and cache distinguished in Linux?
Both buffer and cache occupy memory regions.
When the CPU needs to write data to disk, it first stores the data in a buffer because disk I/O is slow; the buffer data is periodically flushed to disk.
When the CPU reads data from disk, frequently accessed data is pre‑loaded into cache, allowing the CPU to fetch it much faster from cache.3. Meaning of Linux runlevels 0‑6
0: Halt (shutdown)
1: Single‑user mode (used for root password recovery)
2: Multi‑user mode without network support
3: Multi‑user mode with network (text mode, most commonly used)
4: Reserved (unused)
5: Multi‑user mode with X‑Windows (graphical desktop)
6: Reboot4. Linux boot process from power‑on to login screen
① BIOS self‑test and load from hard disk.
② Read MBR and start MBR bootloader.
③ GRUB boot menu (boot loader).
④ Load the kernel.
⑤ Start init process according to the runlevel defined in /etc/inittab.
⑥ init runs rc.sysinit.
⑦ Load kernel modules and execute scripts for the selected runlevel.
⑧ Execute /etc/rc.d/rc.local.
⑨ Start mingetty to present the login prompt.5. Difference between hard links and soft (symbolic) links
Hard link: created by default with ln; shares the same inode as the source file.
Soft link: created with ln -s; has a different inode and stores the path to the source.
Hard links cannot be created for directories; soft links can.
Deleting a soft link does not affect the source file; deleting a hard link leaves the source intact until all hard links are removed.
Soft links can cross filesystem boundaries; hard links cannot.6. Purpose of the "$?" variable in shell scripts
"$?" holds the exit status of the most recently executed command. A value of 0 indicates success; any non‑zero value indicates failure.
Example:
$ ls /usr/bin/
$ echo $?
0
$ ls /nonexistent
ls: cannot access /nonexistent: No such file or directory
$ echo $?
27. Show timestamps in the history command
HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S"
export HISTTIMEFORMAT
# Add the above to /etc/profile to make it persistent across reboots.8. Find top‑10 IPs by request count in an Nginx access log
# Example command
awk '{print $1}' access.log | sort | uniq -c | sort -nr | head -n 109. Forward local port 80 to port 8080 on 10.0.0.254
iptables -t nat -A PREROUTING -d 10.0.0.254 -p tcp --dport 80 -j DNAT --to-destination 10.0.0.254:808010. Common causes of high load
1. Identify processes with high CPU usage (ps ux).
2. If a Java process is heavy, inspect each thread's CPU usage (ps -Lp <pid>).
3. Trace the problematic thread (jstack <pid>).
Additional notes: Frequent Full GC or infinite loops can also cause load spikes.11. Meaning of each field in /etc/fstab
1st column: device or filesystem to be mounted.
2nd column: mount point.
3rd column: filesystem type.
4th column: mount options.
5th column: dump flag (used by backup utilities).
6th column: fsck order (check order at boot).12. Exclude specific directories when creating a tar archive
tar --exclude=/home/dmtsai --exclude=*.tar -zcvf myfile.tar.gz /home/* /etc13. Generate a random password
mkpasswd -l 8 -C 2 -c 2 -d 4 -s 014. Count TCP connection states
netstat -an | grep '^tcp' | awk '{++s[$NF]} END{for(i in s) print i "\t" s[i]}'15. Recover a forgotten MySQL root password
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql> UPDATE user SET password=PASSWORD('new_password') WHERE user='root';Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
