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.
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.
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?
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,
$ nohup sort emp.lst &
4. It is necessary to terminate the command line with &, even when we are using nohup command.
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.
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)?
d) C and bash
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 _____
Explanation: When the nohup command is used, the shell returns the PID and some shells also display a message. For example,
$ 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.
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?
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?
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.
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.