Unix Questions and Answers – Process Handling Commands – 1

This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Process Handling Commands – 1”.

1. We can run the jobs in the background in UNIX.
a) True
b) False
View Answer

Answer: a
Explanation: Since UNIX is a multitasking system, it allows the user to do more than one job at a time. But there can be only one process in the foreground and the rest of jobs have to run in the background.

2. Shell ___ operator is used for running jobs in the background.
a) $
b) #
c) |
d) &
View Answer

Answer: d
Explanation: The & is the shell operator used to run a process in the background. All we have to do is to terminate the command line with a & symbol, the command will automatically run in the background. For example,

$ sort  -o  emp.lst  &        // emp.lst will be sorted but the command will run in background

3. Which command is used for running jobs in the background?
a) nice
b) ps
c) nohup
d) exec
View Answer

Answer: c
Explanation: The nohup command when prefixed to a command allows execution of the process even after the user has logged out of the system. Background jobs cease to run when a user logs out of the system. This happens because the shell is killed. To avoid this condition, the nohup command can be used. For example,

advertisement
advertisement
$ nohup  sort  emp.lst  &

Note: Join free Sanfoundry classes at Telegram or Youtube

4. It is necessary to terminate the command line with &, even when we are using nohup command.
a) True
b) False
View Answer

Answer: a
Explanation: nohup command allows running jobs in the background even when the user logs out of the system. But it is necessary to terminate the command line with & when using nohup command.
advertisement

5. Which of the following shell(s) allows the user to run jobs in the background even when the user has logged out (without using nohup command)?
a) C
b) bash
c) Korn
d) C and bash
View Answer

Answer: d
Explanation: Background jobs are terminated automatically when the user logs out. But in C shell and bash shell jobs are not terminated even after the user logs out. While this is not the case with Bourne and Korn shells. In these shells, jobs are aborted as soon as the user logs out.

6. When nohup command is used, shells returns the _____
a) PID
b) PPID
c) tty
d) TTy
View Answer

Answer: a
Explanation: When the nohup command is used, the shell returns the PID and some shells also display a message. For example,

advertisement
$ nohup sort  emp.lts &
859                             // PID returned by the shell
Sending output to nohup.out    //message displayed

7. nohup command doesn’t send the standard output of a command to any file.
a) True
b) False
View Answer

Answer: b
Explanation: Some shells display a message when the nohup command is used. In these shells, nohup command sends the standard output of the command to the file nohup.out. If you don’t get this message then you have to make sure that you’ve taken care of the output using redirection, if necessary.

8. What is the PID of the process who takes the parentage of the process run with nohup command?
a) 0
b) 1
c) 2
d) Infinite
View Answer

Answer: b
Explanation: The shell dies on logging out but it’s child didn’t. The kernel handles such situations by reassigning the PPID of the orphan process to the system’s init process (PID 1), which is the parent of all shells.

9. Which command is used for executing jobs according to their priority?
a) nohup
b) $
c) &
d) nice
View Answer

Answer: d
Explanation: Processes in UNIX system are usually executed with equal priority but sometimes it is necessary to complete high priority jobs at the earliest. For this purpose, UNIX offers nice command. For example,

$ nice wc emp.lst

10. It is better to use & with nice command.
a) True
b) False
View Answer

Answer: a
Explanation: UNIX offers the nice command, which is used with the & operator to increase the priority of jobs. More important jobs can have greater access to the system resources. For example,

$ nice wc -l emp.lst  &

Sanfoundry Global Education & Learning Series – Unix.

To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.