Explore key concepts in Bash process management with this quiz, covering job control, UNIX signals, and process scheduling essentials. Strengthen your understanding of foreground and background jobs, signal handling, and basic scheduling commands for efficient terminal use.
Which symbol allows you to run a command such as 'sleep 60' in the background in Bash?
Explanation: The ampersand symbol (u0026) lets you execute commands in the background in Bash, allowing the terminal to be free for other input. The hash symbol (#) is used for comments and does not affect process control. The dollar sign ($) refers to variables or command substitution, and the exclamation mark (!) is for event or history expansion. Only u0026 launches background jobs.
If you want to list all jobs you started in your current Bash session, which command should you use?
Explanation: The jobs command displays the status of all jobs started in the current shell, showing which are running or stopped. The ps command lists all processes for the user, not just those started as jobs. The ls command is for listing directories and files, while 'showjobs' is not a standard Bash command. Therefore, jobs is the correct choice.
After stopping a job using Ctrl+Z, which Bash command brings the job back to the foreground?
Explanation: Using fg resumes a stopped job by bringing it to the foreground, allowing terminal input and output to interact with the process. The bg command resumes the job in the background instead, so it will not accept keyboard input. 'Start' and 'resume' are not standard Bash job control commands, making fg the correct answer.
Which command can you use to send a SIGTERM signal to a process with PID 1234?
Explanation: The kill command is used to send signals to processes by their process ID, with the default signal being SIGTERM. 'Stop', 'terminate', and 'end' are not valid Bash commands for sending signals. Typing 'kill 1234' will attempt to terminate the process gracefully with SIGTERM.
By default, which signal does the Bash kill command send if no signal is specified?
Explanation: When you use kill without specifying a signal, it sends the SIGTERM signal by default, requesting the process to terminate gracefully. SIGKILL, SIGSTOP, and SIGCONT require explicit specification and serve different purposes—SIGKILL for forceful termination, SIGSTOP to pause, and SIGCONT to continue a stopped process. Only SIGTERM is the default.
If a job is stopped (shown as 'Stopped' in jobs output), which command allows you to resume it in the background?
Explanation: The bg command continues a suspended job in the background, so you can keep using the terminal. The fg command resumes it in the foreground. 'Cont' is not a standard command (though SIGCONT is a signal), and 'back' does not exist in Bash job control. Therefore, bg is correct.
Which Bash command runs 'my_script.sh' with lower priority using the default nice increment?
Explanation: nice my_script.sh starts the script with a lower priority than normal, using the default nice increment of 10. Specifying -n -5 would increase its priority, not lower it. 'Slow' and 'runlow' are not Bash commands for scheduling. Only nice my_script.sh applies the default behavior for a lower-priority process.
In Bash, how do you refer to the job number 2 when using job control commands?
Explanation: The percent sign followed by the job number (e.g., %2) is used to specify a job in commands like fg or bg. #2 and $2 are either not used in this context or refer to different shell concepts. 'Job2' is not valid Bash syntax. Only %2 correctly refers to job number 2.
Which keyboard shortcut sends an interrupt signal (SIGINT) to the current foreground process in Bash?
Explanation: Ctrl+C interrupts the current foreground process by sending SIGINT, which usually stops the process immediately. Ctrl+Z suspends the process (SIGTSTP), Ctrl+S stops the terminal output (flow control), and Ctrl+F moves the cursor forward. Only Ctrl+C stops the process with SIGINT.
To see a list of all currently running processes for all users in Bash, which command should you use?
Explanation: ps -ef shows a comprehensive list of all running processes on the system, across all users. The jobs -l command only lists jobs started in your current shell. ls -a lists files and directories, not processes. 'Procview' is not a standard Bash command. Therefore, ps -ef is the correct answer.