Linux Commands
From KevinWiki
(Difference between revisions)
		
		
|  (Created page with "= Linux Commands (Practical Use) =  == Kill Processes Found by <code>ps</code> == e.g.) Killing flash  * Get the running flash processes  $ ps aux | grep flash  <pre> username   ...") | |||
| (One intermediate revision not shown) | |||
| Line 1: | Line 1: | ||
| + | [[Category:Linux]] | ||
| = Linux Commands (Practical Use) = | = Linux Commands (Practical Use) = | ||
| Line 28: | Line 29: | ||
| * Use the process IDs to kill the processes | * Use the process IDs to kill the processes | ||
|   $ kill -9 `ps aux | grep flash | grep -v grep | awk '{ print $2; }'` |   $ kill -9 `ps aux | grep flash | grep -v grep | awk '{ print $2; }'` | ||
| + | |||
| + | * Use alias | ||
| + |  $ vim ~/.bash_aliases  | ||
| + | <pre> | ||
| + | alias psflash='ps aux | grep flash | grep -v grep | awk "{ print \$2; }"'  | ||
| + | alias killflash='kill -9 `ps aux | grep flash | grep -v grep | awk "{ print \\$2; }"`'  | ||
| + | # OR | ||
| + | # alias killflash="kill -9 \`ps aux | grep flash | grep -v grep | awk '{ print \$2; }'\`"  | ||
| + | </pre> | ||
Latest revision as of 18:06, 23 January 2013
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; }'`
- Use alias
$ vim ~/.bash_aliases
alias psflash='ps aux | grep flash | grep -v grep | awk "{ print \$2; }"' 
alias killflash='kill -9 `ps aux | grep flash | grep -v grep | awk "{ print \\$2; }"`' 
# OR
# alias killflash="kill -9 \`ps aux | grep flash | grep -v grep | awk '{ print \$2; }'\`" 
				
				
	
