Explore essential concepts of process management in Bash, including background jobs, signals, and job scheduling. This quiz is designed to reinforce your understanding of Bash commands and techniques for effective process control and job handling.
Which Bash symbol allows you to run a process in the background, as seen in the command sleep 60 u0026?
Explanation: The ampersand 'u0026' placed at the end of a bash command sends the process to run in the background, letting you continue using the terminal. The hash symbol '#' is used for comments in Bash scripts and does not affect job control. The dollar sign '$' denotes variables or shell prompts, while the asterisk '*' is a wildcard character. Only 'u0026' initiates a background process.
If you have a background job with job number 1, which Bash command brings it to the foreground?
Explanation: The 'fg %1' command brings the background job with job number 1 to the foreground, allowing it to receive input. The 'bg' command resumes jobs in the background, 'kill' terminates a process, and 'run' is not a Bash command for job control. Only 'fg %1' correctly moves the job to the foreground.
What Bash command displays your currently running jobs and their statuses in the terminal?
Explanation: 'jobs' lists all background and stopped jobs started from the current shell, showing their status. 'ps' shows processes for the whole system or a user but not specifically jobs related to your shell. 'show' and 'list' are not valid Bash commands for this task. Therefore, 'jobs' is the correct answer.
Which command is commonly used in Bash to send a signal, like SIGTERM, to a running process by its process ID (PID)?
Explanation: The 'kill' command sends signals to processes identified by their PID, such as sending a SIGTERM to stop them gracefully. 'Terminate', 'signal', and 'end' might sound relevant but are not default Bash commands for this function. Only 'kill' is the correct built-in tool for signaling processes by PID.
What is the purpose of using 'nohup' before a command, as in nohup python myscript.py u0026?
Explanation: 'nohup' allows a command to continue running after you log out or close the terminal, protecting it from SIGHUP signals. It does not increase process priority (which is done with 'nice') and does not create a new terminal window or schedule tasks (which is achieved with 'crontab'). Only the first option accurately describes 'nohup's' purpose.
If you have stopped a job with Ctrl+Z, how can you resume it in the background using Bash?
Explanation: The 'bg' command resumes a stopped job in the background so you can continue using the terminal. 'Resume', 'continue', and 'run-bg' are not standard Bash job control commands; they will result in errors. Therefore, 'bg' is the only correct and effective option.
Which Bash command schedules a one-time execution of a command such as echo 'Backup Complete' at a specified time?
Explanation: The 'at' command is used to schedule a one-time task at a specific time. 'Cron' schedules recurring tasks with crontab, 'later' and 'timer' are not default Bash tools for scheduling. Only 'at' can carry out a single, scheduled execution.
In Bash, which character is used to refer to a job by its job number, such as %2 to refer to job number 2?
Explanation: The percent symbol '%' is used to refer to jobs by their job numbers in Bash, like '%2' for job 2. The hash '#' is for comments, 'u0026' runs tasks in the background, and '$' relates to variables or commands. Only '%' appropriately references job numbers in job control commands.
What signal does 'kill' send by default to a process if no signal is specified, aiming for graceful termination?
Explanation: 'SIGTERM' is the default signal sent by 'kill', allowing a process to clean up before ending. 'SIGKILL' forces an immediate stop without cleanup, 'SIGSTOP' stops (pauses) the process, and 'SIGCONT' resumes a stopped process. Only 'SIGTERM' is sent by default and allows for graceful termination.
Which Bash command displays detailed information about all running processes on the system?
Explanation: 'ps aux' provides a comprehensive list of all system processes, displaying extensive details. The 'jobs' command only shows jobs in the current shell session, 'showall' and 'list -all' are not valid Bash commands. Thus, 'ps aux' is the correct way to view all running processes.