commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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:
Example: killall - HUP firefox
Closes all instances processes matching firefox.
Purges DNS cache of OS X.
dscacheutil -flushcache does not work since OS X 10.7.
I use this loop for a variety of things. If a process won't die, I try to ask it nicely to let it die gracefully, and then i use killall and kill -9 to end its life. This will run the program killall and then start it again when it completes, indefinately.
The other 2 commands that are listed will also kill the egrep process and any libexec processes because the .exe isn't escaped so it is really using . meaning anything containing exe. The command i posted escapes the (dot) in .exe and then filters the actual egrep process so that it doesn't get killed before the other processes being killed. Also added the -9 switch for kill to send sigterm to the processes, in case people are wondering why processes aren't getting killed after running just kill . This should work better for people :)
* ps -ef # list running processes
* grep string
* pull the process names from 8th field
* cut and delimiter '/'
* print 4th field
* get rid of trailing grep
* for loop killall -9 $i which is the process name
Insert an additional (moveable) spacer on the right side of the Dock in Mac OS X
Insert an additional (moveable) spacer on the left side of the Dock in Mac OS X
requires sp-auth installed
This command will auto kill sp-sc after vlc is closed, so u wont have to do it manually
This is usefull when we don't know the exact name of the process, but the application name
A limitation is that the regular expression only tries to match the last part of the full command (i.e. the bin file name itself).
But this is way shorter than the following one:
ps axww | grep SomeCommand | awk '{ print $1 }' | xargs kill
Place it in your bashrc and running the command radio it will turn on or off each time it runs. Only one command needed. Obviously you can set it to any station you like.
This command is suitable to use as application launching command for a desktop shortcut. It checks if the application is already running by pgrepping its process ID, and offer user to kill the old process before starting a new one.
It is useful for a few x11 application that, if re-run, is more likely a mistake. In my example, x2vnc is an x11 app that does not quit when its connection is broken, and would not work well when a second process establish a second connection after the first broken one.
The LC_ALL=C for xmesseng is necessary for OpenSUSE systems to avoid a bug. If you don't find needing it, remove the "env LC_ALL=C" part
Use this if you can't type repeated killall commands fast enough to kill rapidly spawning processes.
If a process keeps spawning copies of itself too rapidly, it can do so faster than a single killall can catch them and kill them. Retyping the command at the prompt can be too slow too, even with command history retrieval.
Chaining a few killalls on single command line can start up the next killall more quickly. The first killall will get most of the processes, except for some that were starting up in the meanwhile, the second will get most of the rest, and the third mops up.
"killall -USR1 dd" does not work in OS X for me. However, sending INFO instead of USR1 works.
every 1sec sends DD the USR1 signal which causes DD to print its progress.
The following command will clone usb stick inside /dev/sdc to /dev/sdd
Double check you got the correct usb sticks (origional-clone)with fdisk -l.