Probably posted previously, I use this all the time to find and kill a process for "APP". Simply replace "APP" with the name of the process you're looking to kill.
The description of how the one-liner works is here at my blog: http://jugad2.blogspot.com/2008/09/unix-one-liner-to-kill-hanging-firefox.html Show Sample Output
Kill -9 immediately kills the given process number. $$ is the process ID of the process you are in.
I use this command, within a cron job, to kill XMMS after a certain amount of time. This command returns the PID used by XMMS, and gets passed to the kill command. Another alternative would be ps aux | grep xmms | grep -v grep | awk '{ print $2 }' | xargs kill
This is an attempt to get a command which I can alias. It's ugly but it works. I'm hoping someone can suggest a cleaner version. I have tried.... # alias kfire="for i in $( ps aux | grep [F]irefox | awk \'{print $2}\' ); do kill $; done" # alias kfire=`kill $(ps aux | grep [F]irefox | awk '{print $2}' | tr '\n' ' ')` # alias kfire='ps au | grep -i [F]irefox | awk \'{ print $2 \'} ' and they all fail in a .bashrc I've tried escaping the quotes and can't find a way to make the single quotes ' that awk wants work. Maybe I'm just stubborn but I don't want to put in a little #!/bin/bash file just so I can kill a firefox process all in one stroke. This script works (it kills the process before it errors out)... it's just ugly and there may be a pretty way to do this. Show Sample Output
I have some problems with gnome panel which does not load completely leaving me without the actual GUI. This commands helps to kill the gnome-panel process then it should be relaunch automatically.
defunct processes (zombies) usually have to be killed by killing their parent processes. this command retrieves such zombies and their immediate parents and kills all of the matching processes.
Find and kill multiple instances of a process with one simple command.
This command kills all wine instances and each EXE application working on a PC. Here is command info: 1) ps ax > processes = save process list to file named "processes" (we save it because we don't wont egrep to be found in the future) 2) cat processes | egrep "*.exe |*exe]" = shows the file "processes" and after greps for each *.exe and *exe] in it 3) | awk '{ print $1 }' > pstokill = saves processes PID's to file "pstokill" using awk filter 4) kill $(cat pstokill) = kills each PID in file pstokill, which is shown by cat program 5) rm processes && rm pstokill = removes temporary files Show Sample Output
# define user pid to kill PID=httpd ; # kill all pids ps aux | grep $PID | grep -v grep | awk '{print $2}' | xargs kill -9 Show Sample Output
Did some research and found the previous command wrong, we don't kill a zombie but its parent. Just made some modifcation to khashmeshab's command.
Just find out the daemon with $ netstat -atulpe. Then type in his name and he gets the SIGTERM.
Best way I know to get rid of .bash_history and don't allow bash to save the current one on exit Edit: added ~/ before .bash_history, just in case... ;)
This will kill a specific process you don't know the PID of, when pidof and pgrep are not available, for example on OS X. var1 is created so that the whitespace can be trimmed before passing off to kill. Show Sample Output
The pgrep retrieves the PID, then the KILL receive it, and kill it... It works also if the application has more than one instance.... Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: