One linux command every day (42): kill Command

Source: Internet
Author: User
Tags touch command
One linux command every day (42): link to the kill Command: One linux command every day (1): ls command http://www.2cto.com/os/201210/163049.html ; One linux command every day (2): cd command http://www.2cto.com/os/201210/163050.html A linux command (42): kill Command every day link: A linux command (1): ls command every day http://www.2cto.com/os/201210/163049.html ; One linux command every day (2): cd command http://www.2cto.com/os/201210/163050.html ; One linux command every day (3): pwd command http://www.2cto.com/os/201210/163462.html ; One linux command every day (4): mkdir command http://www.2cto.com/os/201210/163463.html ; One linux command every day (5): rm command http://www.2cto.com/os/201210/163662.html ; One linux command (6) every day: rmdir command http://www.2cto.com/os/201210/164017.html ; One linux command (7) every day: mv command http://www.2cto.com/os/201210/164247.html ; One linux command every day (8): cp command http://www.2cto.com/os/201210/164254.html ; One linux command every day (9): touch Command http://www.2cto.com/os/201211/165699.html ; One linux command every day (10): cat command http://www.2cto.com/os/201211/165989.html ; One linux command every day (11): nl command http://www.2cto.com/os/201211/165990.html One linux command every day (12): more command http://www.2cto.com/os/201211/165994.html One linux command every day (13): less command http://www.2cto.com/os/201211/165998.html One linux command every day (14): head Command http://www.2cto.com/os/201211/166191.html One linux command every day (15): tail command http://www.2cto.com/os/201211/168702.html One linux command every day (16): which command http://www.2cto.com/os/201211/168890.html A linux command (17) every day: whereis command http://www.2cto.com/os/201211/168893.html One linux command (18) every day: locate command http://www.2cto.com/os/201211/168895.html One linux command every day (19): find command overview http://www.2cto.com/os/201211/168897.html One linux command every day (20): find command exec http://www.2cto.com/os/201211/168901.html One linux command (21) every day: find command xargs http://www.2cto.com/os/201211/168903.html A linux command (22) every day: detailed description of the parameters of the find Command http://www.2cto.com/os/201211/168912.html A linux command (23) every day: Linux directory structure http://www.2cto.com/os/201211/170430.html One linux command every day (24): Linux file type and extension http://www.2cto.com/os/201211/170431.html One linux command every day (25): Explanation of linux file attributes http://www.2cto.com/os/201211/170434.html One linux command every day (26): use SecureCRT to upload and download files http://www.2cto.com/os/201211/172022.html One linux command every day (27): linux chmod command http://www.2cto.com/os/201211/172028.html One linux command every day (28): tar command http://www.2cto.com/os/201212/172641.html One linux command (29) every day: chgrp command http://www.2cto.com/os/201212/172983.html One linux command every day (30): chown command http://www.2cto.com/os/201212/173239.html A linux command (31) every day:/etc/group file details http://www.2cto.com/os/201212/174429.html One linux command (32) every day: gzip command http://www.2cto.com/os/201212/174431.html One linux command every day (33): df command http://www.2cto.com/os/201212/174434.html One linux command every day (34): du command http://www.2cto.com/os/201212/174701.html One linux command (35) every day: ln command http://www.2cto.com/os/201212/174993.html One linux command (36) every day: diff command http://www.2cto.com/os/201212/176333.html One linux command (37) every day: date Command http://www.2cto.com/os/201212/176335.html One linux command (38) every day: cal command http://www.2cto.com/os/201212/176337.html One linux command (39) every day: grep command http://www.2cto.com/os/201212/177059.html One linux command every day (40): wc command http://www.2cto.com/os/201212/177343.html One linux command every day (41): ps command http://www.2cto.com/os/201212/177665.html The kill command in Linux is used to terminate the running of a specified process. it is a common command for process management in Linux. Generally, you can use Ctrl + C to terminate a foreground process. However, for a background process, you must use the kill command to terminate it, we need to first use ps/pidof/pstree/top and other tools to obtain the process PID, and then use the kill command to kill the process. The kill command ends a process by sending a specified signal to the process. By default, the TERM signal numbered 15 is used. The TERM signal terminates all processes that cannot capture the signal. For processes that can capture this signal, use the kill signal numbered 9 to forcibly "kill" the process. Www.2cto.com 1. command format: kill [parameter] [process number] 2. command function: Send the specified signal to the corresponding process. If no model is specified, SIGTERM (15) is sent to terminate the specified process. If the program cannot be terminated and the "-KILL" parameter is available and the signal sent is SIGKILL (9), the process is forcibly terminated. you can run the ps command or the jobs command to view the process number. Root users will affect user processes. non-root users can only affect their processes. 3. command parameter:-l signal. if the serial number parameter is not added, the "-l" parameter will be used to list all the signal names-a when processing the current process, do not restrict the correspondence between command names and process numbers-p specify the kill command to print only the process numbers of the relevant process, without sending any signal-s specify the sending signal-u specify the user's attention: 1. the kill command can contain the signal number option or not. If there is no signal number, the kill Command will send a termination signal (15), which can be captured by the process so that the process can clear and release resources before exiting. You can also use kill to send specific signals to the process. For example, kill-2 123 is equivalent to pressing Ctrl + C when running a process with a PID of 123 on the foreground. However, common users can only use the kill command without the signal parameter or use a maximum of-9 signals. 2. kill can contain a process ID as a parameter. When sending signals to these processes with kill, they must be the masters of these processes. If you try to undo a process without permission or undo a non-existent process, you will get an error message. 3. you can send signals to or terminate multiple processes. 4. After kill successfully sends a signal, the shell will display the process termination information on the screen. Sometimes this information is not immediately displayed. it is only displayed when the shell command prompt appears again by pressing Enter. 5. it should be noted that the process is forcibly terminated by a signal, which often brings some side effects, such as data loss or the terminal cannot be restored to normal. When sending a signal, you must be careful. only when you have to do so can you use the kill signal (9), because the process cannot capture it first. To cancel all background jobs, enter kill 0. Some commands run in the background will start multiple processes, and it is very troublesome to trace and find the PID of all processes to be killed. Kill 0 is an effective method to terminate all processes started by the current shell. 4. use instance: instance 1: list all signal names command: kill-l output: [root @ localhost test6] # kill-l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR213) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH29) SIGIO 30) SI GPWR 31) SIGSYS 34) SIGRTMIN35) SIGRTMIN + 1 36) SIGRTMIN + 2 37) SIGRTMIN + 3 38) SIGRTMIN + 439) SIGRTMIN + 5 40) SIGRTMIN + 6 41) SIGRTMIN + 7 42) SIGRTMIN + 843) SIGRTMIN + 9 44) SIGRTMIN + 10 45) SIGRTMIN + 11 46) SIGRTMIN + 1247) SIGRTMIN + 13 48) SIGRTMIN + 14 49) SIGRTMIN + 15 50) SIGRTMAX-1451) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-1055 56) SIGRTMAX-9 57) SIGRTMAX-8 58) SIGRTMAX-7 SIG RTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-263 64) SIGRTMAX description: only 9th kinds of signal (SIGKILL) can unconditionally terminate the process, other signal process has the right to ignore. Below are common signals: HUP 1 terminal disconnection INT 2 interrupt (same as Ctrl + C) QUIT 3 QUIT (same as Ctrl + \) TERM 15 terminate KILL 9 force terminate CONT 18 continue (opposite to STOP, fg/bg command) STOP 19 pause (same as Ctrl + Z) instance 2: Get the value command for the specified signal: output: [root @ localhost test6] # kill-l KILL9 [root @ localhost test6] # kill-l SIGKILL9 [root @ localhost test6] # kill-l TERM15 [root @ localhost test6] # kill-l SIGTERM15 [root @ localhost test6] # description: instance 3: First use ps to find the process, and then use kill to kill the command: kill 3268 output: [root @ localhost test6] # ps-ef | Grep vim root 3268 2884 0 00:00:00 pts/1 vim install. logroot 3370 2822 0 00:00:00 pts/0 grep vim [root @ localhost test6] # kill 3268 [root @ localhost test6] # kill 3268-bash: kill: (3268) -No process [root @ localhost test6] # Note: instance 4: kill-9 3268 command output: [root @ localhost test6] # ps-ef | grep vim root 3268 2884 0 00:00:00 pts/1 vim install. logroot 3370 2822 0 00:00:00 pts/0 grep vim [r Oot @ localhost test6] # kill-9 3268 [root @ localhost test6] # kill 3268-bash: kill: (3268)-no process [root @ localhost test6] # description: instance 5: Command for killing all processes of a specified user: kill-9 $ (ps-ef | grep peidalinux) kill-u peidalinux output: [root @ localhost ~] # Kill-9 $ (ps-ef | grep peidalinux) [root @ localhost ~] # Kill-u peidalinux description: Method 1: filter out hnlinux user processes and kill instances. 6: the init process is a kill-9 Command. output: [root @ localhost ~] # Ps-ef | grep initroot 1 0 0 Nov02? 00:00:00 init [3] root 17563 17534 0 00:00:00 pts/1 grep init [root @ localhost ~] # Kill-9 1 [root @ localhost ~] # Kill-HUP 1 [root @ localhost ~] # Ps-ef | grep initroot 1 0 0 Nov02? 00:00:00 init [3] root 17565 17534 0 00:00:00 pts/1 grep init [root @ localhost ~] # Kill-KILL 1 [root @ localhost ~] # Ps-ef | grep initroot 1 0 0 Nov02? 00:00:00 init [3] root 17567 17534 0 00:00:00 pts/1 grep init [root @ localhost ~] # Note: init is an indispensable program in Linux system operations. The init process is a user-level process started by the kernel. After the kernel is started by itself (it has been loaded into the memory, started to run, and initialized to all the device drivers and data structures), it starts a user-level program init, complete the boot process. Therefore, init is always the first process (its process number is always 1 ). All other processes are descendants of the init process. The init process cannot be killed!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.