Linuxでプロセスを強制終了するコマンド
$ ps -ef
root 723 1 0 Feb20 ? 00:00:04 /sbin/dhclient -1 -q -lf /var/li
root 774 1 0 Feb20 ? 00:00:04 /sbin/rsyslogd -i /var/run/syslo
dbus 825 1 0 Feb20 ? 00:00:00 dbus-daemon –system
root 841 1 0 Feb20 ? 00:00:00 cupsd -C /etc/cups/cupsd.conf
68 871 1 0 Feb20 ? 00:00:00 hald
root 872 871 0 Feb20 ? 00:00:00 hald-runner
nscd 929 1 0 Feb20 ? 00:00:31 /usr/sbin/nscd
root 949 1 0 Feb20 ? 00:00:00 /usr/sbin/sshd
root 1193 1 0 Feb20 ? 00:00:30 /usr/libexec/postfix/master
postfix 1211 1193 0 Feb20 ? 00:00:04 qmgr -l -t fifo -u
root 1216 1 0 Feb20 ? 00:00:01 abrt-dump-oops -d /var/spool/abr
root 1225 1 0 Feb20 ? 00:00:00 /usr/sbin/abrtd
root 1233 1 0 Feb20 ? 00:00:20 crond
root 1250 1 0 Feb20 ? 00:00:00 /usr/sbin/atd
nginx 1288 6324 0 Apr22 ? 00:15:41 php-fpm: pool www
nginx 1297 6324 0 Apr22 ? 00:15:39 php-fpm: pool www
nginx 1298 6324 0 Apr22 ? 00:14:11 php-fpm: pool www
$ ps -aux
smx 1822 0.1 0.8 58484 18152 ? Sl 11:38 0:49 gnome-terminal
smx 1823 0.0 0.0 1988 712 ? S 11:38 0:00 gnome-pty-helper
smx 1824 0.0 0.1 6820 3776 pts/0 Ss 11:38 0:02 bash
smx 1827 4.3 5.8 398196 119568 ? Sl 11:38 26:13 /usr/lib/firefox-28.0/firefox-bin
smx 1857 0.0 0.1 6688 3644 pts/1 Ss 11:38 0:00 bash
smx 1880 0.0 0.6 41536 12620 ? S 11:38 0:00 update-notifier
smx 11953 0.0 0.0 2716 1064 pts/0 R+ 21:42 0:00 ps -aux
firefoxプロセスを強制終了
kill -9 1827
改善1:grepを使う
$ ps -ef | grep firefox
smx 1827 1 4 11:38 ? 00:27:33 /usr/lib/firefox-28.0/firefox-bin
smx 12029 1824 0 21:54 pts/0 00:00:00 grep –color=auto firefox
改善2 pgrepを使う
$ pgrep firefox
1827
改善3 pidofを使う
$ pidof firefox-bin
1827
改善4
$ps -ef | grep firefox | grep -v grep | cut -c 9-15 | xargs kill -s 9