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:
This appends (-A) a new rule to the INPUT chain, which specifies to drop all packets from a source (-s) IP address.
The tee (as in "T" junction) command is very useful for redirecting output to two places.
If you bork your terminal by sending binary data to STDOUT or similar, you can get your terminal back using this command rather than killing and restarting the session. Note that you often won't be able to see the characters as you type them.
Useful when quickly looking for a commit id from a branch to use with git cherry-pick.
This spiders the given site without downloading the HTML content. The resulting directory structure is then parsed to output a list of the URLs to url-list.txt. Note that this can take a long time to run and you make want to throttle the spidering so as to play nicely.
This recursively downloads all images from a given website to your /tmp directory. The -nH and -nd switches disable downloading of the directory structure.
This runs the uptime command every 30 seconds to avoid an SSH connection dropping due to inactivity. Granted there are better ways of solving this problem but this is sometimes the right tool for the job.
The --force option bypasses the warning if files are already in SVN.
Simple use of find and grep to recursively search a directory for files that contain a certain term.
You will be prompted for a password unless you have your public keys set-up.
Really useful for when you have a typo in a previous command. Also, arguments default to empty so if you accidentally run:
echo "no typozs"
you can correct it with
^z
Uses shell expansion to create a back-up called file.txt.bak
This grabs all lines that make an instantation or static call, then filters out the cruft and displays a summary of each class called and the frequency.
Sed stops parsing at the match and so is much more effecient than piping head into tail or similar. Grab a line range using
sed '999995,1000005!d' < my_massive_file
Using xargs is better than:
find /path/to/dir -type f -exec rm \-f {} \;
as the -exec switch uses a separate process for each remove. xargs splits the streamed files into more managable subsets so less processes are required.
This greps all PHP files for a given classname and displays both the file and the usage.
Useful when you forget to use sudo for a command. "!!" grabs the last run command.
For when you want to flush all content from a file without removing it (hat-tip to Marc Kilgus).
This can be useful when a large remove operation is taking place.
This is an alternative to cron which allows a one-off task to be scheduled for a certain time.
This uses awk to grab the IP address from each request and then sorts and summarises the top 10.