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
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
Which command shows all running processes in Linux?
a) ls
b) ps
c) top
d) jobs
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
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
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
Which command can you use to see processes running in the background?
a) ps
b) fg
c) jobs
d) kill
Which command is used to bring a background job to the foreground?
a) fg
b) bg
c) jobs
d) ps
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
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
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
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
Which of the following is used to send a job to the background in Linux?
a) bg
b) fg
c) jobs
d) ps
How can you stop a running job in the foreground?
a) Ctrl + Z
b) Ctrl + C
c) Ctrl + D
d) Ctrl + X
Which signal is sent when you use Ctrl + C in the terminal?
a) SIGTERM
b) SIGKILL
c) SIGSTOP
d) SIGINT
How can you resume a stopped job in the background?
a) fg
b) bg
c) jobs
d) ps
What is the command to list the currently running jobs in the shell?
a) jobs
b) ps
c) top
d) kill
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
Which command is used to run a job without being terminated when the user logs out?
a) bg
b) nohup
c) fg
d) exit
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
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
Which command is used to kill a process in Linux?
a) ps
b) kill
c) wait
d) jobs
What signal does the kill command send by default to terminate a process?
a) SIGTERM
b) SIGKILL
c) SIGSTOP
d) SIGINT
How can you kill a process using its pid?
a) kill <pid>
b) killall <pid>
c) ps <pid>
d) stop <pid>
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
How do you list all processes, including those owned by other users?
a) ps
b) ps -u
c) ps -A
d) ps -a
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
Which signal is used to immediately terminate a process with kill?
a) SIGKILL
b) SIGTERM
c) SIGINT
d) SIGSTOP
Which command would you use to list processes in real-time?
a) ps
b) top
c) jobs
d) kill
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
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
Qno
Answer
1
a) A running instance of a program
2
b) ps
3
a) By its ID
4
c) A process that runs in the background without user interaction
5
c) The process identification number
6
c) jobs
7
a) fg
8
a) A background task running in the terminal
9
a) By using the & symbol
10
a) Lists background jobs
11
b) Brings a background job to the foreground
12
a) bg
13
a) Ctrl + Z
14
d) SIGINT
15
b) bg
16
a) jobs
17
a) Runs the command in the background
18
b) nohup
19
b) The command will be paused and sent to the background