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:
Ever use 'locate' to find a common phrase in a filename or directory name? Often you'll get a huge list of matches, many of which are redundant, and typically the results are not sorted. This command will 'locate' your search phrase, then show you a sorted list of just the relevant directories, with no duplications. So, for example, maybe you have installed several versions of the java jre and you want to track down every directory where files matching "java" might exist. Well, a 'locate java' is likely to return a huge list with many repeated directories since many files in one directory could contain the phrase "java". This command will whittle down the results to a minimal list of unique directory names where your search phrase finds a match.
This command lists all packages in a yum based system that no other packages depend on. Hence, these packages are good candidates for removal. It's a great command for cleaning up a yum based distribution after installation.
If you are already running screen then you often want to start a command in a fresh window. You use this alias by typing 's whatever' from your command line and 'whatever' starts running in a new window. Good with interactive commands like info, vim, and nethack.
Kill all processes with foo in them. Similar to pkill but more complete and also works when there is no pkill command.
Works on almost every Linux/Unix platform I have tried.
To make it even more practical, make sure you can login to the ssh server using a keypair.
pgrep is an useful tool which looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. pkill can also be used with pgrep to send a kill signal to the program.
Fool date by setting the timezone out by 24 hours and you get yesterday's date. Try TZ=XYZ-24 to get tomorrow's date. I live in TZ=GMT0BST so you might need to shift the number 24 by the hours in your timezone.
I find this handy for linking all the bin files in a package to /usr/bin or all the man files to /usr/share/man. You can replace * with */* to operate on all the files in subdirectories.
great for running off a bootable cd to identify hardware other os's can't detect
We use this to quickly highlight differences and provide a quick way to cut and paste the command to view the files using the marvellous vimdiff
-O switch creates local filename same as remote
curl  -o #1#2 makes local files unique inserting sequence values into #x placeholders
sequences can be alpha or numeric e.g [a-z] [1-25]
Subtitles' file names contain S04E01, S04E02, ... S04E12 and end with ".smi".
Videos' file names contain S04E01, S04E02, ... S04E12 and end with ".avi".
You can change the patterns by changing `ls *S04E$jj*.smi` and `ls *S04E$jj*.avi` parts.
You can change the number of starting and ending file by changing `seq -f "%02.0f" 1 12` part.
Replaces every ocurrence of 'old' for 'new' in all files specified. After the 'i' char you can put a '~' or whatever to create a backup file for each replaced with the name equal to the original plus character.
just for fun
Useful if you have to tunnel ssh through a local port and it complains of the host key being different. Much easier than manually editing the file.