Kill(2)
Содержание:
Say hello to killall command
The killall is a Linux only command. It may be available on FreeBSD and other Unix like systems such as macOS to kill processes by name. So no need to find the PIDs using the ‘pidof process’ or ‘ps aux | grep process’ commands. Do not use the killall command on Solaris Unix operating systems. The syntax is:
killall {Process-Name-Here}
killall -9 {Process-Name-Here}
killall -15 {Process-Name-Here}
|
To kill the lighttpd server, enter: OR To kill the Firefox web-browser process, enter: As I said earlier, the killall command on UNIX-like system does something else. It kills all process and not just specific process. Do not use killall on UNIX system. See your local man page for more info by typing the man command:
Examples
In these examples, if a command is listed as /bin/kill, it should be run with that version of the kill command. Other commands may be run with built-in kill.
kill -9 -1
Kill all processes the user has permission to kill, except the root process (PID 1) and the kill process itself.
kill -l
List all available signal names. Sample output:
HUP INT QUIT ILL TRAP ABRT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH POLL PWR SYS
/bin/kill -l
Same as the previous command.
/bin/kill --list
Same as the previous two commands.
/bin/kill -L
List available signals and their numbers in a table format. Sample output:
1 HUP 2 INT 3 QUIT 4 ILL 5 TRAP 6 ABRT 7 BUS 8 FPE 9 KILL 10 USR1 11 SEGV 12 USR2 13 PIPE 14 ALRM 15 TERM 16 STKFLT 17 CHLD 18 CONT 19 STOP 20 TSTP 21 TTIN 22 TTOU 23 URG 24 XCPU 25 XFSZ 26 VTALRM 27 PROF 28 WINCH 29 POLL 30 PWR 31 SYS
/bin/kill --table
Same as the previous command.
/bin/kill --list=11
Translate signal number 11 into its signal name. Output:
SEGV
kill 123 4567
Sends the default signal (KILL, signal number 9) for the processes with IDs 123 and 4567. Those processes are terminated.
How to Kill a Process in Linux
Let us try to kill a process that is called firefox. To find firefox pid run any one of the following commands:
Locating the process (PID) to kill on Linux Each process is automatically assigned a unique process identification number (PID) in Linux. In this example it is 27707.
Force kill process on Linux command line
To kill process on Linux use the kill command: By default signal 15, named SIGTERM, is sent to kill process. Hence all of the following are doing same things: Verify that firefox process gone: There are many signals that can be used with kill, but, most users will only need to be aware of signal 9 and 15. To get full list, run: Sample outputs:
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR 31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8 43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2 63) SIGRTMAX-1 64) SIGRTMAX |
How to Kill a Process in Linux using SIGKILL
Sometime -SIGTERM (-15) fails, the stronger signal 9, called SIGKILL, should be used for force killing of process. For example, the following command would guarantee that process 27707 would be killed:
Syntax
The basic syntax is as follows:
kill PID
OR
kill -s signalName PID
OR
kill -signalName PID
OR
kill -signalNumber PID
Where,
- signalNumber : A non-negative decimal integer, specifying the signal to be sent instead of the default TERM.
- signalName : A symbolic signal name specifying the signal to be sent instead of the default TERM.
- PID : Specify the list of processes that kill should signal. Each PID can be any one of the following:
- n : If PID is a positive value, the kill command sends the process whose process ID is equal to the PID.
- : All processes in the current process group are signaled.
- -1 : All processes with pid larger than 1 will be signaled i.e. the kill command sends the signal to all processes owned by the effective user of the sender.
Common Linux and UNIX signal names and numbers
All available UNIX signals have different names, and are mapped to certain numbers as described below:
| Number | Name (short name) | Description | Used for |
|---|---|---|---|
| SIGNULL (NULL) | Null | Check access to pid | |
| 1 | SIGHUP (HUP) | Hangup | Terminate; can be trapped |
| 2 | SIGINT (INT) | Interrupt | Terminate; can be trapped |
| 3 | SIGQUIT (QUIT) | Quit | Terminate with core dump; can be trapped |
| 9 | SIGKILL (KILL) | Kill | Forced termination; cannot be trapped |
| 15 | SIGTERM (TERM) | Terminate | Terminate; can be trapped |
| 24 | SIGSTOP (STOP) | Stop | Pause the process; cannot be trapped. This is default if signal not provided to kill command. |
| 25 | SIGTSTP (STP) | Terminal | Stop/pause the process; can be trapped |
| 26 | SIGCONT (CONT) | Continue | Run a stopped process |
Note the specific mapping between numbers and signals can vary between Unix implementations, please see the manual page entry signal(5), by typing the following command:
man 5 signal |
OR
man 7 signal |
A list of Specifies signal names are stored in /usr/include/sys/signal.h; so use more command to view the same:
Listing System Processes
The process status (ps) command lists the processes that are associated with your shell.
# ps
For each process, the ps command displays the PID, the terminal identifier (TTY), the cumulative execution time (TIME), and the command name (CMD). For example, list the currently running processes on the system using the ps command.
# ps PID TTY TIME CMD 1442 pts/1 00:00:00 sudo 1448 pts/1 00:00:00 su 1449 pts/1 00:00:00 bash 1666 pts/1 00:00:00 ps
The ps command has several options that you can use to display additional process information.
- -a: Prints information about all processes most frequently requested, except process group leaders and processes not associated with a terminal
- -e: Prints information about every process currently running
- -f: Generates a full listing
- -l: Generates a long listing
- -o format: Writes information according to the format specification given in a format. Multiple -o options can be specified. The format specification is interpreted as the space-character-separated concatenation of all the format option arguments.
Истории по дате
|
|
|
|
|
318 |
|
|
|
|
#3309
30 апреля 2010, 12:05
родители
Мой отец — полное ничтожество и опасный тип. Он пьет, каждый день устраивает в подъезде истерики с рыданиями и ором на радость соседям, постоянно оскорбляет меня и маму, все время пьяным забывает то газ выключить, то с сигаретой горящей засыпает, столько раз могла случиться беда!
По закону мы не можем сдать его на принудительное лечение в психушке, потому, что нужно его согласие и не доказано то, что он опасен для общества. Что, нам ждать, пока он кого-нибудь зарежет или сожжет полдома? Тогда нам поверят?
КМП, не хочу жить в постоянном страхе и стыде.
Пристрелить (+)
4345
Да ну, фигня (-)
#3308
30 апреля 2010, 11:05
друзья
полгода назад меня изнасиловали….заявление не подала,так как он мой друг….он всем рассказал,что я сама на него полезла…некоторые верят и осуждают,хотя я им даже синяки показывала…КМП
Пристрелить (+)
3697
Да ну, фигня (-)
#3307
30 апреля 2010, 10:00
отношения
жил с ней 3 года и в горе и в радости..сегодня она засобиралась на очередную гулянку..я дал выбор «я или гулянка», она выбрала не меня..убейте лоха, до кучи узнал что все деньги она потратила..
кмп
Пристрелить (+)
2123
Да ну, фигня (-)
#3306
29 апреля 2010, 19:15
отношения
Назначен день свадьбы, куплены платье, кольца и торт, внесена предоплата за ресторан, все родственники рады и с нетерпением ждут знаменательного дня. С того момента, как сделал ей предложение, прошло 3 месяца. И все три месяца дома скандалы, практически каждый день. Не могу сказать, что в них виновата невеста, — я тоже не промах. Но жить так уже больше не могу, такое ощущение, что мы просто не можем найти общий язык.
Вот и думаю, что делать: отменять свадьбу, пока не поздно, или терпеть и надеяться, что после свадьбы все наладится…
ПМП
Пристрелить (+)
2730
Да ну, фигня (-)
#3305
29 апреля 2010, 18:15
отношения
Она хочет замуж! Уже 4 года хочет, а я не хочу жениться, но ее люблю и не против быть вместе. Мне 25, я еще не хочу семью! Меня достали истерики и причитания. КМП
Пристрелить (+)
-1658
Да ну, фигня (-)
#3304
29 апреля 2010, 17:15
учеба
,
работа
,
отношения
Выгнали из универа. Позвонили с работы — сказали что могу больше не приходить. Девушка бросила под предлогом, что «устала» от меня. По дороге домой избили гопники. ПМП
Пристрелить (+)
5802
Да ну, фигня (-)
#3303
29 апреля 2010, 16:15
отношения
Мне 19 лет, с 15 лет встречаюсь с девушкой, которая старше меня на 4 года, я ей не разу не изменял (при том что она у меня первая). Два года назад она залетела, ждали малыша, но она мне изменила в 1 же месяц беременности — итог выкидыш. Спустя больше года — на мой день рожденье — переспала с моим пьяным знакомым, итог — эрозия шейки матки. после это начала ходить налево регулярно. уже последние полгода предлагаю ей расстаться — не хочет, говорит я ей нужен. шантажирует тем что распространит мои интим фотки (ну пофоткала она меня как то давно) по всему городу (городок у нас не большой).
теперь ежедневно практически терплю позор — она всем называеться моей девушкой и со всеми е…ться
килл ми плизз, мне надоело быть посмешищем….
Пристрелить (+)
5142
Да ну, фигня (-)
#3302
29 апреля 2010, 15:10
родители
мне 18 лет. сегодня мои родители меня избили за то что я погнула тоненькую зарядку для нокии. КМП, я не могу больше с ними жить, нервы на пределе.
Пристрелить (+)
5660
Да ну, фигня (-)
#3301
29 апреля 2010, 14:10
разное
Началось всё с того, что нашёл на даче с другом бутылку ликёра 80го года выпуска. Приехали домой, открыли а он малость не свежий, но всё равно ели выпили. Потом решили идти в клуб. Пришли в один, туда не пустили, пошли во второй, тот закрыт, пошли в третий, но не успели до закрытия! В итоге пили пиво на улице в 5 утра. Далее я на машине влетаю в ужасную яму, в итоге бампер в хлам, подкрылок отлетел, задний бампер слетел с креплений, повело балку заднюю. Далее на следующий день узнаю, что был выгнан с работы, ибо весь день возился с починкой машины и немного забыл обо всём. Вечером-же мне звонят из деканата и сообщают, что я отчислен из ВУЗа..следующий день мою машину несколько раз бьёт створкой ворот открывшейся из-за ветра, итог сломанное зеркало, покорябаная дверь.
КМП
Пристрелить (+)
-970
Да ну, фигня (-)
#3300
29 апреля 2010, 13:10
семья
Мужчина с которым давно встречается моя мама оказался отцом парня с которым сейчас встречаюсь я.
К тому же он врал маме о том что он в разводе.
ПМП
Пристрелить (+)
2270
Да ну, фигня (-)
|
|
|
|
|
318 |
|
|
|
|
Use System Monitor to Kill a Linux Process
The next option is to open your Linux operating system’s System Monitor utility. This is typically found in the System Tools menu and displays a list of running processes under the Processes tab.
To close an unresponsive application here, simply select it and right-click. You then have three options:
- Stop Process: This pauses the process, letting you continue it later. It won’t work in most cases.
- End Process: The correct way to close a process, this will safely terminate the application, cleaning temporary files on the way.
- Kill Process: This is the extreme option and should only be used if End Process fails.
It’s best to use these in order. However, if the application is one that hangs regularly, you might prefer to use a command that you know works.