UNIX MCQs – Background and Foreground Processes (Part -1)

UNIX Question and Answer – Background and Foreground Processes

UNIX MCQ – Multiple Choice Questions for exam, interview, and Entrance Test

1. What UNIX command is used to move a suspended process to the background?

a) bg

b) fg

c) kill

d) jobs

Answer: a) bg

Explanation: The bg command is used to move a suspended process to the background in UNIX.


2. Which command is used to bring a background process to the foreground in UNIX?

a) bg

b) fg

c) kill

d) jobs

Answer: b) fg

Explanation: The fg command is used to bring a background process to the foreground in UNIX.


3. What UNIX command is used to display a list of background jobs?

a) bg

b) fg

c) kill

d) jobs

Answer: d) jobs

Explanation: The jobs command is used to display a list of background jobs in UNIX.


4. In UNIX, how can a running foreground process be suspended?

a) Pressing Ctrl+C

b) Pressing Ctrl+Z

c) Pressing Ctrl+D

d) Pressing Ctrl+S

Answer: b) Pressing Ctrl+Z

Explanation: Pressing Ctrl+Z suspends a running foreground process in UNIX.


5. What happens to a background process when the shell session ends in UNIX?

a) It is terminated

b) It continues running

c) It is moved to the foreground

d) It is paused indefinitely

Answer: a) It is terminated

Explanation: When the shell session ends, background processes are terminated in UNIX.


6. Which command is used to send a signal to a process in UNIX?

a) bg

b) fg

c) kill

d) jobs

Answer: c) kill

Explanation: The kill command is used to send a signal to a process in UNIX.


7. In UNIX, what signal is sent to terminate a process gracefully?

a) SIGINT

b) SIGKILL

c) SIGTERM

d) SIGSTOP

Answer: c) SIGTERM

Explanation: SIGTERM is the signal sent to terminate a process gracefully in UNIX.


8. What command is used to change the priority of a running process in UNIX?

a) nice

b) renice

c) pri

d) top

Answer: b) renice

Explanation: The renice command is used to change the priority of a running process in UNIX.


9. In UNIX, how can a background process be terminated?

a) fg

b) kill

c) jobs

d) bg

Answer: b) kill

Explanation: The kill command is used to terminate a background process in UNIX.


10. What UNIX command is used to display the status of all processes?

a) ps

b) top

c) pstree

d) process

Answer: a) ps

Explanation: The ps command is used to display the status of all processes in UNIX.


11. Which signal is sent to suspend a process in UNIX?

a) SIGSTOP

b) SIGTSTP

c) SIGINT

d) SIGTERM

Answer: b) SIGTSTP

Explanation: SIGTSTP is the signal sent to suspend a process in UNIX.


12. What is the purpose of the nice command in UNIX?

a) Send signals to processes

b) Change the priority of a process

c) Display a list of background jobs

d) Display system load information

Answer: b) Change the priority of a process

Explanation: The nice command is used to change the priority of a process in UNIX.


13. In UNIX, how can a process be resumed from the suspended state?

a) fg

b) bg

c) kill

d) jobs

Answer: a) fg

Explanation: The fg command is used to resume a process from the suspended state in UNIX.


14. Which command is used to send a signal to restart a process in UNIX?

a) stop

b) restart

c) reload

d) kill -HUP

Answer: d) kill -HUP

Explanation: The kill command with the -HUP option is used to send a signal to restart a process in UNIX.


15. In UNIX, what command is used to display information about the current shell session?

a) shell

b) term

c) tty

d) session

Answer: c) tty

Explanation: The tty command is used to display information about the current shell session in UNIX.


16. What is the purpose of the disown command in UNIX?

a) Suspend a process

b) Terminate a process

c) Remove a process from the shell’s job table

d) Bring a process to the foreground

Answer: c) Remove a process from the shell’s job table

Explanation: The disown command is used to remove a process from the shell’s job table in UNIX.


17. In UNIX, what is the default action of the kill command without any signal specified?

a) Terminate the process

b) Suspend the process

c) Resume the process

d) Bring the process to the foreground

Answer: a) Terminate the process

Explanation: By default, the kill command terminates the process in UNIX.


18. What signal is sent to a process when the Ctrl+C key combination is pressed?

a) SIGSTOP

b) SIGTSTP

c) SIGINT

d) SIGTERM

Answer: c) SIGINT

Explanation: SIGINT is the signal sent to a process when the Ctrl+C key combination is pressed in UNIX.


19. What is the primary purpose of the jobs command in UNIX?

a) Display a list of background jobs

b) Send signals to processes

c) Change the priority of processes

d) Terminate processes

Answer: a) Display a list of background jobs

Explanation: The jobs command is used to display a list of background jobs in UNIX.


20. In UNIX, how can a suspended process be terminated?

a) fg

b) bg

c) kill

d) jobs

Answer: c) kill

Explanation: The kill command is used to terminate a suspended process in UNIX.


21. What UNIX command is used to display the current process ID?

a) pid

b) getpid

c) ps

d) jobs

Answer: b) getpid

Explanation: The getpid command is used to display the current process ID in UNIX.


22. In UNIX, what happens to a foreground process when it receives the SIGTERM signal?

a) It is suspended

b) It is resumed

c) It is terminated

d) It is sent to the background

Answer: c) It is terminated

Explanation: A foreground process is terminated when it receives the SIGTERM signal in UNIX.


23. Which command is used to send a signal to stop a process in UNIX?

a) stop

b) kill -STOP

c) suspend

d) pause

Answer: b) kill -STOP

Explanation: The kill command with the -STOP option is used to send a signal to stop a process in UNIX.


24. In UNIX, what is the significance of the & symbol when used with a command?

a) It redirects output to a file

b) It runs the command as a background process

c) It runs the command as a foreground process

d) It pipes output to another command

Answer: b) It runs the command as a background process

Explanation: The & symbol is used to run a command as a background process in UNIX.


25. What is the purpose of the wait command in UNIX?

a) Suspend a process until it receives a signal

b) Terminate a process

c) Bring a process to the foreground

d) Wait for background processes to complete

Answer: d) Wait for background processes to complete

Explanation: The wait command is used to wait for background processes to complete in UNIX.


26. Which command is used to resume a suspended background process in UNIX?

a) bg

b) fg

c) kill

d) jobs

Answer: a) bg

Explanation: The bg command is used to resume a suspended background process in UNIX.


27. What UNIX command is used to send a signal to a specific process?

a) bg

b) fg

c) kill

d) jobs

Answer: c) kill

Explanation: The kill command is used to send a signal to a specific process in UNIX.


28. In UNIX, what is the purpose of the nohup command?

a) Run a command with elevated privileges

b) Run a command in the background and ignore hangup signals

c) Run a command as a foreground process

d) Run a command without any output

Answer: b) Run a command in the background and ignore hangup signals

Explanation: The nohup command is used to run a command in the background and ignore hangup signals in UNIX.


29. Which signal is sent to a process when the Ctrl+Z key combination is pressed?

a) SIGSTOP

b) SIGTSTP

c) SIGINT

d) SIGTERM

Answer: b) SIGTSTP

Explanation: SIGTSTP is the signal sent to a process when the Ctrl+Z key combination is pressed in UNIX.


30. What is the primary purpose of the disown command in UNIX?

a) Suspend a process

b) Terminate a process

c) Remove a process from the shell’s job table

d) Bring a process to the foreground

Answer: c) Remove a process from the shell’s job table

Explanation: The disown command is used to remove a process from the shell’s job table in UNIX.


31. In UNIX, how can a process be terminated gracefully?

a) fg

b) bg

c) kill -TERM

d) jobs

Answer: c) kill -TERM

Explanation: The kill command with the -TERM option is used to terminate a process gracefully in UNIX.


32. What is the purpose of the nice command in UNIX?

a) Send signals to processes

b) Change the priority of a process

c) Display a list of background jobs

d) Display system load information

Answer: b) Change the priority of a process

Explanation: The nice command is used to change the priority of a process in UNIX.


33. In UNIX, how can a background process be terminated?

a) fg

b) kill

c) jobs

d) bg

Answer: b) kill

Explanation: The kill command is used to terminate a background process in UNIX.


34. What UNIX command is used to display the current process ID?

a) pid

b) getpid

c) ps

d) jobs

Answer: b) getpid

Explanation: The getpid command is used to display the current process ID in UNIX.


35. In UNIX, what happens to a background process when the shell session ends?

a) It is terminated

b) It continues running

c) It is moved to the foreground

d) It is paused indefinitely

Answer: a) It is terminated

Explanation: When the shell session ends, background processes are terminated in UNIX.


36. Which command is used to send a signal to restart a process in UNIX?

a) stop

b) restart

c) reload

d) kill -HUP

Answer: d) kill -HUP

Explanation: The kill command with the -HUP option is used to send a signal to restart a process in UNIX.


37. In UNIX, what is the default action of the kill command without any signal specified?

a) Terminate the process

b) Suspend the process

c) Resume the process

d) Bring the process to the foreground

Answer: a) Terminate the process

Explanation: By default, the kill command terminates the process in UNIX.


38. What signal is sent to a process when the Ctrl+C key combination is pressed?

a) SIGSTOP

b) SIGTSTP

c) SIGINT

d) SIGTERM

Answer: c) SIGINT

Explanation: SIGINT is the signal sent to a process when the Ctrl+C key combination is pressed in UNIX.


39. In UNIX, what is the significance of the & symbol when used with a command?

a) It redirects output to a file

b) It runs the command as a background process

c) It runs the command as a foreground process

d) It pipes output to another command

Answer: b) It runs the command as a background process

Explanation: The & symbol is used to run a command as a background process in UNIX.


40. What is the purpose of the wait command in UNIX?

a) Suspend a process until it receives a signal

b) Terminate a process

c) Bring a process to the foreground

d) Wait for background processes to complete

Answer: d) Wait for background processes to complete

Explanation: The wait command is used to wait for background processes to complete in UNIX.


41. Which command is used to send a signal to stop a process in UNIX?

a) stop

b) kill -STOP

c) suspend

d) pause

Answer: b) kill -STOP

Explanation: The kill command with the -STOP option is used to send a signal to stop a process in UNIX.


42. In UNIX, what is the purpose of the trap command?

a) Run a command in the background

b) Handle signals received by the shell or scripts

c) Display system load information

d) Manage user sessions

Answer: b) Handle signals received by the shell or scripts

Explanation: The trap command is used to handle signals received by the shell or scripts in UNIX.


43. What is the primary purpose of the bg command in UNIX?

a) Bring a background process to the foreground

b) Move a suspended process to the background

c) Terminate a background process

d) Suspend a foreground process

Answer: b) Move a suspended process to the background

Explanation: The bg command is used to move a suspended process to the background in UNIX.


44. Which signal is sent to a process when the Ctrl+D key combination is pressed?

a) SIGKILL

b) SIGTERM

c) SIGHUP

d) SIGQUIT

Answer: c) SIGHUP

Explanation: SIGHUP is the signal sent to a process when the Ctrl+D key combination is pressed in UNIX.


45. What is the purpose of the fg command in UNIX?

a) Move a process to the foreground

b) Move a process to the background

c) Terminate a process

d) Display a list of background jobs

Answer: a) Move a process to the foreground

Explanation: The fg command is used to move a process to the foreground in UNIX.


46. In UNIX, what happens to a foreground process when it receives the SIGKILL signal?

a) It is suspended

b) It is resumed

c) It is terminated

d) It is sent to the background

Answer: c) It is terminated

Explanation: A foreground process is terminated when it receives the SIGKILL signal in UNIX.


47. Which command is used to send a signal to a process by name in UNIX?

a) killall

b) pkill

c) pskill

d) killbyname

Answer: b) pkill

Explanation: The pkill command is used to send a signal to a process by name in UNIX.


48. In UNIX, what is the primary purpose of the renice command?

a) Change the name of a process

b) Change the priority of a process

c) Change the owner of a process

d) Change the group of a process

Answer: b) Change the priority of a process

Explanation: The renice command is used to change the priority of a process in UNIX.


49. What signal is sent to a process when the Ctrl+Z key combination is pressed?

a) SIGSTOP

b) SIGTSTP

c) SIGINT

d) SIGTERM

Answer: b) SIGTSTP

Explanation: SIGTSTP is the signal sent to a process when the Ctrl+Z key combination is pressed in UNIX.


50. In UNIX, what is the primary purpose of the at command?

a) Schedule a one-time task to be executed at a specific time

b) Schedule a recurring task to be executed at regular intervals

c) Execute a command at a specific time without scheduling

d) Display the list of scheduled tasks

Answer: a) Schedule a one-time task to be executed at a specific time

Explanation: The at command is used to schedule a one-time task to be executed at a specific time in UNIX.

Related Articles

Linux MCQ

Welcome to Linux Multiple Choice Questions (MCQ) Section Embark on a journey through the world of...