Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I would like to know what are the different types of kill command in linux. i.e. kill, kill -0, kill -9, skill, pkill, killall, killproc, kill -SIGHUP, kill -HUP etc. What are their purpose and when to use it?
See kill -l for a full list. All the kill command real does is send a signal to the target process(es). The other commands you list are variations on this basic theme -- read their man pages for more details. How the process responds depends on how (and if) it's set up to interpret that signal. The only signals processes can't have handlers for are SIGKILL (number 9, hence the infamous kill -9) and SIGSTOP (forcibly suspends process execution). Many of the other signals date back to days of yore when folks interacted with computers via teletypes and dial-in lines (e.g. SIGHUP used to mean that the terminal line had physically hung up, but now processes often interpret this to mean restart execution or reopen log files).
The only signals end users need to worry about are generally SIGINT, SIGKILL, SIGTSTP, and SIGSTOP. The first to kill a process (SIGKILL forcibly, without giving a process a chance to handle the signal, so it's not a good idea to do that unless you have no other choice), e.g. in most cases pressing CTRL+C sends SIGINT to the foreground process. Likewise the latter two stop a process (SIGSTOP forcibly). SIGTSTP is what CTRL+Z sends top suspend a process, for example.
So it's a little bit complicated ... kill sends a signal (which may or may not terminate the process). Within limits, what the process does with that signal can be defined by the program.
Fun facts: init cannot be killed, even with kill -9. Processes in state D (I/O wait) will not be signaled until their state changes, as it's unsafe to terminate processes with locks on I/O buffers.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.