Explore key concepts of process management and signal handling in Unix/Linux systems with this quiz. Assess your understanding of commands, signals, and techniques involved in controlling processes using examples and practical scenarios.
Which signal is sent by default when the 'kill' command is used without specifying a signal, such as in 'kill 1234'?
Explanation: The default signal sent by the 'kill' command is SIGTERM, which requests the process to terminate gracefully. SIGKILL would force termination but must be explicitly specified, such as 'kill -9 1234'. SIGSTOP suspends a process and SIGCONT resumes it; neither is used by default with 'kill'.
If a process was started in the background with 'u0026', which command brings its most recent job to the foreground?
Explanation: The 'fg' command brings the most recent background job into the foreground, allowing user interaction. 'bg' resumes a stopped job in the background but does not bring it to the foreground. 'jobs' lists active jobs, and 'ps' shows process status, but neither changes process states.
Which keyboard shortcut sends the SIGTSTP signal to a running foreground process to pause it?
Explanation: Pressing Ctrl+Z in a terminal sends the SIGTSTP signal, suspending the current foreground process. Ctrl+C sends SIGINT to interrupt a process, while Ctrl+D logs out of the terminal or sends EOF. Ctrl+S controls terminal flow but does not pause processes.
What command provides a real-time list of active processes and their statuses?
Explanation: 'top' displays a dynamic, real-time view of currently running processes and their statuses. 'grep' searches for patterns in text, 'ls' lists directory contents, and 'sudo' executes commands with superuser privileges, but none show real-time process information.
Which of the following signals cannot be caught, blocked, or ignored by a process?
Explanation: SIGKILL immediately terminates a process and cannot be intercepted, handled, or blocked. SIGUSR1, SIGINT, and SIGTERM can be handled by processes, allowing them to perform cleanup or ignore the signal in some cases.
How can you send the SIGUSR1 signal to a process with PID 5432 from the command line?
Explanation: 'kill -USR1 5432' sends the user-defined signal SIGUSR1 to process 5432. The basic 'kill 5432' sends SIGTERM. 'kill -9 5432' sends SIGKILL, and 'kill -HUP 5432' sends SIGHUP, none of which are SIGUSR1.
After suspending a process with Ctrl+Z, which command resumes it in the background?
Explanation: 'bg' resumes a suspended job in the background, so the shell remains available for other commands. 'fg' brings the job to the foreground. 'stop' is not used as a command for jobs, and 'suspend' stops a shell session, not a process.
Which UNIX signal is typically ignored by default by most programs?
Explanation: SIGCHLD is sent to a parent when a child process terminates, and is usually ignored unless the parent is programmed to handle it. SIGKILL forces termination and cannot be ignored. SIGTERM and SIGINT are processed and usually lead to termination unless explicitly handled.
What is the name of the unique integer number assigned to each process in Unix/Linux?
Explanation: PID stands for Process ID, which uniquely identifies each running process. UID is the User ID, GID is the Group ID, and SID refers to Session ID, but only PID is assigned to processes.
If you want to continuously monitor the output of a process with PID 2222, which command would be most appropriate?
Explanation: 'strace -p 2222' attaches to the running process and displays its system calls, allowing for real-time monitoring. 'ls -l' lists file details, 'echo 2222' prints the number, and 'chmod 2222' attempts to change file permissions, which are unrelated to process output monitoring.