Process Management in Bash: Jobs, Signals, and Scheduling Quiz Quiz

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.

  1. Running Processes in the Background

    Which symbol allows you to run a command such as 'sleep 60' in the background in Bash?

    1. !
    2. u0026
    3. #
    4. $

    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.

  2. Viewing Background Jobs

    If you want to list all jobs you started in your current Bash session, which command should you use?

    1. ps
    2. ls
    3. jobs
    4. showjobs

    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.

  3. Continuing a Stopped Job

    After stopping a job using Ctrl+Z, which Bash command brings the job back to the foreground?

    1. start
    2. bg
    3. fg
    4. resume

    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.

  4. Sending a Signal to a Process

    Which command can you use to send a SIGTERM signal to a process with PID 1234?

    1. stop 1234
    2. end 1234
    3. kill 1234
    4. terminate 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.

  5. Default Signal with the Kill Command

    By default, which signal does the Bash kill command send if no signal is specified?

    1. SIGKILL
    2. SIGTERM
    3. SIGCONT
    4. SIGSTOP

    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.

  6. Bringing a Suspended Job to the Background

    If a job is stopped (shown as 'Stopped' in jobs output), which command allows you to resume it in the background?

    1. bg
    2. back
    3. cont
    4. fg

    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.

  7. Process Scheduling with nice

    Which Bash command runs 'my_script.sh' with lower priority using the default nice increment?

    1. nice my_script.sh
    2. nice -n -5 my_script.sh
    3. slow my_script.sh
    4. runlow my_script.sh

    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.

  8. Identifying Job Numbers

    In Bash, how do you refer to the job number 2 when using job control commands?

    1. %2
    2. #2
    3. job2
    4. $2

    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.

  9. Terminating a Foreground Process

    Which keyboard shortcut sends an interrupt signal (SIGINT) to the current foreground process in Bash?

    1. Ctrl+Z
    2. Ctrl+C
    3. Ctrl+F
    4. Ctrl+S

    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.

  10. Monitoring All Processes

    To see a list of all currently running processes for all users in Bash, which command should you use?

    1. procview
    2. ls -a
    3. jobs -l
    4. ps -ef

    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.