Unix Questions and Answers – Process Handling Commands – 2

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.
a) internal
b) external
c) built-in
d) directory
View Answer

Answer: c
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.
a) -a
b) -n
c) -o
d) -q
View Answer

Answer: b
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?
a) signal
b) nice
c) kill
d) nohup
View Answer

Answer: c
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,

advertisement
advertisement
$ 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 !
View Answer

Answer: c
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,

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
$ sort  -o  emp.lst &        
467
$ kill $!             // kills the sort command

5. By default, kill uses the SIGTERM signal (15) to terminate the process.
a) True
b) False
View Answer

Answer: a
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.
advertisement

6. Which signal is used with kill command to terminate the process when they ignore the SIGTERM signal (15)?
a) SIGTERM (16)
b) SIGTERM(0)
c) SIGKILL(9)
d) -d
View Answer

Answer: c
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:

advertisement
$ kill -9  134

7. Which option is preferred while killing a process using SIGKILL signal (9)?
a) -p
b) -s
c) -h
d) -d
View Answer

Answer: b
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
View Answer

Answer: d
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.
a) True
b) False
View Answer

Answer: a
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.

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.