Linux Commands

From KevinWiki

Revision as of 17:42, 23 January 2013 by Kevin (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Linux Commands (Practical Use)

Kill Processes Found by ps

e.g.) Killing flash

  • Get the running flash processes
$ ps aux | grep flash 
username    5488  3.4  0.7 732108 114580 ?       Sl   04:28   0:13 /path/to/app --type=plugin --plugin-path=/usr/lib/flashplugin-installer/libflashplayer.so
username    5591  1.3  0.2 410888 33128 ?        Sl   04:35   0:00 /usr/lib/firefox/plugin-container /usr/lib/flashplugin-installer/libflashplayer.so
username    5602  0.0  0.0  14812   912 pts/3    S+   04:35   0:00 grep --color=auto flash
  • Exclude the process to grep flash
$ ps aux | grep flash | grep -v grep 
username    5488  3.4  0.7 732108 114580 ?       Sl   04:28   0:13 /path/to/app --type=plugin --plugin-path=/usr/lib/flashplugin-installer/libflashplayer.so
username    5591  1.3  0.2 410888 33128 ?        Sl   04:35   0:00 /usr/lib/firefox/plugin-container /usr/lib/flashplugin-installer/libflashplayer.so
  • Get only the process IDs
$ ps aux | grep flash | grep -v grep | awk '{ print $2; }' 
5488
5591
  • Use the process IDs to kill the processes
$ kill -9 `ps aux | grep flash | grep -v grep | awk '{ print $2; }'`
Personal tools