This set of Unix Questions and Answers for Entrance exams focuses on “Process Handling Commands – 2”.
1. nice command is a ______ command in C shell.
Explanation: nice is a built-in command in the C shell. nice values are system-dependent and typically range from 1 to 19. A higher nice value implies a lower priority. nice reduces the priority of any process.
2. Which option can be used explicitly to reduce the priority of any process.
Explanation: nice values are system-dependent and typically range from 1 to 19. We can also specify the nice value explicitly with the -n option but a non-privileged user cannot increase the priority of a process. For example, to increase the priority by 8 times use the following command:
$ nice -n 5 wc -l emp.lst &
3. Which command is used for premature termination of a process?
Explanation: The kill command is used for premature termination of a process. It usually sends a signal with the intention of killing one or more processes. kill is an internal command in most shells. Kill command uses one or more PID’s as its arguments. For example,
$ kill 105 // terminates the job having PID 105
4. Which one of the following command is used for killing the last background job?
a) kill $
b) kill $$
c) kill $!
d) kill !
Explanation: For most shells, the system variable $! Stores the PID of the last background job. So we can kill any process by using kill command. The PID of the job can be seen when & is affixed to a command. For example,
$ sort -o emp.lst & 467 $ kill $! // kills the sort command
5. By default, kill uses the SIGTERM signal (15) to terminate the process.
Explanation: UNIX often requires to communicate the occurrence of events to process. This is done by sending a signal. The SIGTERM signal (15) is the default signal used by the kill command to terminate processes.
6. Which signal is used with kill command to terminate the process when they ignore the SIGTERM signal (15)?
a) SIGTERM (16)
Explanation: By default, the SIGTERM signal (15) is used by the kill command to terminate processes. But sometimes it may happen that some programs ignore it and continue their execution normally. In such a case, the process can be killed by using SIGKILL signal (9). For example, to kill a job with PID 134 use the following command:
$ kill -9 134
7. Which option is preferred while killing a process using SIGKILL signal (9)?
Explanation: Sometimes it may happen that some programs ignore the SIGTERM signal (15) and continue their execution normally. In such a case, the process can be killed by using SIGKILL signal (9). This signal can’t be generated at the press of a key, so we have to use KILL with the signal name preceded with -s option. For example, to kill a job with PID 184 use the following command:
$ kill -s KILL 184
8. Which of the followings command(s) is used to kill the login shell?
a) kill 0
b) kill -9 $$
c) kill -s KILL 0
d) kill -9 $$ and kill -s KILL 0
Explanation: A simple kill command (with TERM) will not kill the login shell. We can kill the login shell by using any of the following commands:
$ kill -9 $$ // $$ stores the PID of current shell $ kill -s KILL 0 // kills all processes including the login shell
9. Kill -l will list all the signal numbers on our machine.
Explanation: To view the list of all signal names and numbers that are available on our machine, we have to use the -l option with kill command or view the file /usr/include/sys/signal.h
Sanfoundry Global Education & Learning Series – Unix.
To practice all areas of Unix for Entrance exams, here is complete set of 1000+ Multiple Choice Questions and Answers.