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.
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:
use this comand to see which switch port your network interface is using.
but remind, there is no network traffic for 10 minutes or how long you run the comand.
if you start the comand via ssh, port will come up again after the "for loop" has endet
Works for any mathematical operation, even converting numbers from one base to another.
this will dump a list of domains one per line into a text file
Creates a git repository in a predefined location.
When you do a ls -1 | xargs rm it wouldn't workd because those files have spaces. So you must use
find -print0 and xargs -0
unzips all zip files in any subdirectory under the current directory. The zip files are unzipped in their respective subdirs
Built-in function in linux, should work on any distro
Doesn't create a file
Make sure to list the files / directories in the same order every time.
apt-show-versions is a program that shows what packages in the system may be updated and several useful information. The -u option displays a list of upgradeable packages:
This will show the locations, in order of preference, that MySQL will look for a configuration file
Ever need to erase the contents of a file and start over from scratch? This easy command allows you to do so. Be warned! This will immediately erase all the contents of your file and start you over from scratch (i.e. your file will be at 0 bytes, like if you touch a file).
But who knows to delete the rest of the lines?
I want only "string".
This will get the mac address of the eth0 and change lowercase to uppercase.
The sed command removed the colons.
ls -l may vary depending on operating system, so "print $8" may have to be changed