Here are key Linux interview questions organized by topic:
Core Concepts
What is the difference between a process and a thread? A process is an independent program with its own memory space; a thread is a lightweight unit within a process sharing the same memory.
What are inodes? Inodes store metadata about files (permissions, ownership, timestamps, disk block locations) but not the filename or file data itself.
Explain the boot process. BIOS/UEFI → Bootloader (GRUB) → Kernel loads → init/systemd starts → runlevel/target reached.
File System
- Hard link vs soft link — Hard links point to the same inode; symlinks point to a path. Deleting the original breaks a symlink but not a hard link.
/procfilesystem — A virtual FS exposing kernel and process info in real time (e.g.,/proc/cpuinfo,/proc/meminfo)./etc/fstab— Defines filesystems to mount at boot.
Permissions & Users
chmod 755— Owner: rwx, Group: r-x, Others: r-xsetuidbit — Runs executable as the file owner (e.g.,passwdruns as root).sudovssu—sudoruns a single command as root;suswitches the entire session to another user.
Processes & Performance
ps auxvstop—ps auxis a snapshot;topis real-time.- Zombie process — A process that has finished but its parent hasn’t called
wait()to read its exit status. nice/renice— Set/change process scheduling priority (-20 highest, 19 lowest).- Check memory usage —
free -h,vmstat,/proc/meminfo
Networking
netstat -tulnp/ss -tulnp— List open ports and listening services.iptablesvsfirewalld— Both manage the kernel netfilter;firewalldis a dynamic wrapper with zones.- Check routing table —
ip routeorroute -n /etc/resolv.conf— Configures DNS nameservers.
Common Commands
| Task | Command |
|---|---|
| Find files by name | find / -name "file.txt" |
| Search inside files | grep -r "pattern" /dir |
| Disk usage | df -h / du -sh * |
| Archive & compress | tar -czf file.tar.gz dir/ |
| Live log watching | tail -f /var/log/syslog |
| Schedule tasks | crontab -e |
systemd
systemctl status/start/stop/enable— Manage services.- Units — Services (
.service), timers (.timer), mounts (.mount), etc. journalctl -u nginx -f— Follow logs for a specific unit.
Shell Scripting
$?— Exit code of the last command (0 = success).$@vs$*— Both hold script arguments;$@treats each as a separate word,$*treats all as one string.2>/dev/null— Redirect stderr to discard errors.
Tricky / Advanced Questions
- What happens when you type a command in the shell? Shell forks a child process →
exec()replaces it with the command → parent waits. - OOM killer — Kernel kills processes when RAM is exhausted; logs in
dmesg. strace— Traces system calls made by a process, useful for debugging.lsof— Lists open files and which processes have them open.