Interview Q&A / Linux & Shell
Linux & Shell interview questions
Permissions, processes, pipes and the commands you are expected to know cold.
Prefer rapid revision? Practise Linux & Shell short interview answers →
- How do you find and stop a process in Linux, and what is the difference between SIGTERM and SIGKILL?
Use ps or top to find the process ID, then kill to send it a signal. SIGTERM (15, the default) politely asks the process to exit so it can clean up, while SIGKILL (9) makes the kernel end it immediately and cannot be caught or ignored.
AdvancedIn-depth3 min read - How do Ctrl+Z, bg, fg and jobs work in a shell?
Ctrl+Z suspends the foreground job, bg resumes it in the background, fg brings it back to the foreground and jobs lists the shell's jobs with numbers. Appending & to a command starts it in the background directly.
BeginnerQuick answer1 min read - How do you find or stop processes by name using pgrep and pkill?
pgrep prints the PIDs of processes whose names match a pattern, and pkill sends them a signal (SIGTERM by default). Use -f to match the full command line and -u to limit to a user. Always run pgrep first to see what would be hit.
BeginnerQuick answer1 min read - What is the difference between ps aux and ps -ef?
Both list every process on the system. ps aux uses BSD-style options and shows %CPU, %MEM and memory sizes; ps -ef uses the POSIX style and shows the parent PID (PPID) and full start time. Choose aux for resource use and -ef for process relationships.
BeginnerQuick answer1 min read - What is the difference between running a command with & and with nohup?
& only puts the command in the background of the current shell; it can still die when the terminal closes. nohup makes the command ignore the hangup signal, so it keeps running after logout, and sends its output to nohup.out unless redirected.
BeginnerQuick answer1 min read - What are nice and renice, and what do the values mean?
nice starts a process with a chosen priority adjustment and renice changes it for a running process. Niceness ranges from -20 (highest priority) to 19 (lowest). Lowering priority with a higher number is polite to others; raising it needs root.
IntermediateQuick answer1 min read - What does load average mean in top and uptime?
Load average is the average number of processes running or waiting for the CPU (and, on Linux, waiting on uninterruptible I/O) over the last 1, 5 and 15 minutes. Compare it with the number of CPU cores: on 4 cores, a load near 4 means fully busy.
IntermediateQuick answer1 min read - What is /proc in Linux, and is it a real folder on disk?
/proc is a virtual file system created by the kernel in memory. Its files show live information about running processes and the system, such as /proc/cpuinfo and /proc/PID/status. Nothing in it is stored on disk.
IntermediateQuick answer1 min read - What is a zombie process, and how do you get rid of it?
A zombie is a process that has finished but still has an entry in the process table because its parent has not read its exit status. It uses no CPU or memory beyond that entry. You fix it by making the parent call wait, restarting the parent, or killing the parent so init adopts and cleans it.
IntermediateQuick answer1 min read