Linux Process Management 4 — Questions and Answers
Question 1: Which command displays the process tree showing parent-child relationships?
- ps -ef
- pstree (Correct answer)
- top -H
- procstat
Correct answer: pstree
pstree displays running processes as a tree, visually showing parent-child relationships between processes.
Question 2: What does 'kill -0 PID' do?
- Terminates the process immediately
- Sends no signal but checks if the process exists and you can signal it (Correct answer)
- Resets the process to its initial state
- Pauses the process
Correct answer: Sends no signal but checks if the process exists and you can signal it
Signal 0 is never actually sent; it only checks whether the process exists and whether the caller has permission to signal it.
Question 3: What is the difference between foreground and background jobs in a shell?
- Background jobs run at lower CPU priority
- Foreground jobs receive terminal input; background jobs do not (Correct answer)
- Background jobs are immune to signals
- Foreground jobs cannot be stopped with Ctrl+Z
Correct answer: Foreground jobs receive terminal input; background jobs do not
Foreground jobs have control of the terminal and receive keyboard input, while background jobs run without terminal control.
Question 4: Which command brings a background job to the foreground?
- bg %1
- fg %1 (Correct answer)
- run %1
- resume %1
Correct answer: fg %1
fg %jobnumber brings the specified background job into the foreground and gives it terminal control.
Question 5: What does the /proc/PID/fd directory contain?
- The process's fork descriptors
- Symbolic links to all file descriptors opened by the process (Correct answer)
- The process's function definitions
- Log files generated by the process
Correct answer: Symbolic links to all file descriptors opened by the process
/proc/PID/fd contains one symbolic link per open file descriptor, pointing to the actual file, socket, or pipe.
Question 6: Which signal is used to reload a daemon's configuration file without restarting it?
- SIGKILL (9)
- SIGTERM (15)
- SIGHUP (1) (Correct answer)
- SIGUSR1 (10)
Correct answer: SIGHUP (1)
SIGHUP (1) was originally a 'hangup' signal but many daemons handle it as a cue to reload their configuration files.
Question 7: What is the init process's PID and why is it special?
- PID 0; it is the idle/swapper process
- PID 1; it is the first userspace process and parent of all others (Correct answer)
- PID 1; it runs in kernel space
- PID 2; it manages kernel threads
Correct answer: PID 1; it is the first userspace process and parent of all others
PID 1 is the init/systemd process — the first userspace process started by the kernel and the ultimate ancestor of all other processes.
Which command displays the process tree showing parent-child relationships?