MCQs on Process Management | Shell Scripting

Process management is a crucial concept in shell scripting and Linux systems. Understanding how processes, jobs, and commands like kill, ps, and jobs work is vital for system administration.


Chapter: Process Management – MCQs

1. Understanding Processes and Jobs

  1. What is a process in Linux?
    • a) A running instance of a program
    • b) A file stored in memory
    • c) A command that is executed
    • d) A list of active users
  2. Which command shows all running processes in Linux?
    • a) ls
    • b) ps
    • c) top
    • d) jobs
  3. In Unix, how is a process identified?
    • a) By its ID
    • b) By its name
    • c) By its size
    • d) By the command it executes
  4. What is a background process in Linux?
    • a) A process that is running in the terminal
    • b) A process that runs when the user is logged out
    • c) A process that runs in the background without user interaction
    • d) A process that occupies the screen
  5. What does the pid represent in a process listing?
    • a) The size of the process
    • b) The time the process started
    • c) The process identification number
    • d) The name of the process
  6. Which command can you use to see processes running in the background?
    • a) ps
    • b) fg
    • c) jobs
    • d) kill
  7. Which command is used to bring a background job to the foreground?
    • a) fg
    • b) bg
    • c) jobs
    • d) ps
  8. What is a job in shell scripting?
    • a) A background task running in the terminal
    • b) A task that has finished execution
    • c) A command in a script file
    • d) A file in the file system
  9. How can you run a command in the background in Linux?
    • a) By using the & symbol
    • b) By using the bg command
    • c) By using the jobs command
    • d) By using the nohup command
  10. What does the command jobs do in Linux?
    • a) Lists background jobs
    • b) Lists all active processes
    • c) Lists current directory jobs
    • d) Executes a script

2. Background and Foreground Jobs

  1. What does the fg command do in Linux?
    • a) Stops a running process
    • b) Brings a background job to the foreground
    • c) Sends a process to the background
    • d) Lists all foreground jobs
  2. Which of the following is used to send a job to the background in Linux?
    • a) bg
    • b) fg
    • c) jobs
    • d) ps
  3. How can you stop a running job in the foreground?
    • a) Ctrl + Z
    • b) Ctrl + C
    • c) Ctrl + D
    • d) Ctrl + X
  4. Which signal is sent when you use Ctrl + C in the terminal?
    • a) SIGTERM
    • b) SIGKILL
    • c) SIGSTOP
    • d) SIGINT
  5. How can you resume a stopped job in the background?
    • a) fg
    • b) bg
    • c) jobs
    • d) ps
  6. What is the command to list the currently running jobs in the shell?
    • a) jobs
    • b) ps
    • c) top
    • d) kill
  7. What does the & symbol do when appended to a command?
    • a) Runs the command in the background
    • b) Runs the command as superuser
    • c) Runs the command in debug mode
    • d) Runs the command in the foreground
  8. Which command is used to run a job without being terminated when the user logs out?
    • a) bg
    • b) nohup
    • c) fg
    • d) exit
  9. What will happen if you press Ctrl + Z while a command is running?
    • a) The command will terminate
    • b) The command will be paused and sent to the background
    • c) The command will continue running in the foreground
    • d) The command will be resumed
  10. How do you send a process to the background after it has been stopped?
    • a) Use bg
    • b) Use fg
    • c) Use jobs
    • d) Use kill

3. Process Control: kill, ps, jobs, wait

  1. Which command is used to kill a process in Linux?
    • a) ps
    • b) kill
    • c) wait
    • d) jobs
  2. What signal does the kill command send by default to terminate a process?
    • a) SIGTERM
    • b) SIGKILL
    • c) SIGSTOP
    • d) SIGINT
  3. How can you kill a process using its pid?
    • a) kill <pid>
    • b) killall <pid>
    • c) ps <pid>
    • d) stop <pid>
  4. What does the ps command do in relation to processes?
    • a) Lists active background jobs
    • b) Lists the status of the running processes
    • c) Executes a process
    • d) Kills a process
  5. How do you list all processes, including those owned by other users?
    • a) ps
    • b) ps -u
    • c) ps -A
    • d) ps -a
  6. What is the function of the wait command in Linux?
    • a) Waits for a job to finish
    • b) Stops a running process
    • c) Starts a process in the background
    • d) Pauses the terminal
  7. Which signal is used to immediately terminate a process with kill?
    • a) SIGKILL
    • b) SIGTERM
    • c) SIGINT
    • d) SIGSTOP
  8. Which command would you use to list processes in real-time?
    • a) ps
    • b) top
    • c) jobs
    • d) kill
  9. What is the result of using the kill -9 <pid> command?
    • a) It terminates the process without cleanup
    • b) It pauses the process
    • c) It restarts the process
    • d) It sends a warning to the process
  10. How can you view detailed information about all processes, including their parent-child relationships?
    • a) ps -e
    • b) ps -f
    • c) ps -a
    • d) ps -l

Answers

QnoAnswer
1a) A running instance of a program
2b) ps
3a) By its ID
4c) A process that runs in the background without user interaction
5c) The process identification number
6c) jobs
7a) fg
8a) A background task running in the terminal
9a) By using the & symbol
10a) Lists background jobs
11b) Brings a background job to the foreground
12a) bg
13a) Ctrl + Z
14d) SIGINT
15b) bg
16a) jobs
17a) Runs the command in the background
18b) nohup
19b) The command will be paused and sent to the background
20a) Use bg
21b) kill
22a) SIGTERM
23a) kill <pid>
24b) Lists the status of the running processes
25c) ps -A
26a) Waits for a job to finish
27a) SIGKILL
28b) top
29a) It terminates the process without cleanup
30b) ps -f

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top