What's this?

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/

Get involved!

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.

Universal configuration monitoring and system of record for IT.

Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





All commands from sorted by
Terminal - All commands - 12,272 results
svn propset svn:ignore "*txt" log/
2009-04-04 23:09:01
Tags: svn

If you don't want to commit files to subversion, and don't want those file to show up when doing an "svn stat", this command is what you need

< /dev/urandom tr -dc A-Za-z0-9_ | head -c $((1024 * 1024)) | tee >(gzip -c > out.gz) >(bzip2 -c > out.bz) > /dev/null
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
2009-04-04 01:41:48
User: peterc
Functions: grep sudo tcpdump

Replace "en1" with your network interface (on OS X, usually en0, en1, eth0, etc..)

diff <(ssh alice cat /etc/apt/sources.list) <(ssh bob cat /etc/apt/sources.list)
/usr/local/bin/svn merge -r {rev_num}:HEAD https://{host}/{project}/branches/{branch_name} .
2009-04-03 15:43:32
User: kamiller
Functions: merge
Tags: svn merge

This will merge all of the changes from {rev_num} to head on the branch to the current working directory

identify -ping imageName.png
rm -rf `find ./ -iname *.svn*`
dmesg | grep cpu
2009-04-03 01:57:04
User: kingji
Functions: dmesg grep
Tags: cpus

get cpu info from dmesg

history | grep ssh
2009-04-03 01:35:52
User: haivu
Functions: grep
Tags: bash csh

After seeing the command you wish to repeat, just invoke it using the ! syntax.

ncal -e
2009-04-02 17:58:27
Tags: ncal dates

ncal -e shows the date of Easter this year. ncal -e YYYY shows the date of Easter in a given year. ncal -o works the same way, but for Orthodox dates.

ls -l | grep ^l
2009-04-02 17:47:36
User: haivu
Functions: grep ls
Tags: ls

Shows all linked file and destinations. The 'ls -l' command lists the files in long (1 file per line) format, and the grep command displays only those lines that starts with an l (lower case L) -- a linked file.

Updated: Remove reference to hard links because this command does not apply to hard link as others kindly pointed out.

cal -3
2009-04-02 17:40:38
User: haivu
Functions: cal
Tags: PIM

the -3 show the previous, current, and next month.

whatis [command-name]
2009-04-02 17:30:13
User: haivu
Functions: whatis

The whatis command displays a short description for the command you list on the command line. It is useful to quickly learn what a command does

sudo vi /etc/fstab; Go//smb-share/gino /mnt/place smbfs defaults,username=gino,password=pass 0 0<esc>:wq; mount //smb-share/gino
2009-04-02 16:04:35
User: GinoMan2440
Functions: mount sudo vi

the middle command between the ; and ; is the vi commands that insert that line into the last line of the file, the esc with the carets is literally hitting the escape key, you have to have the smbfs package installed to do it, I use it to access my iTunes music on my mac from my linux PC's with amarok so I can play the music anywhere in the house. among other things, it allows you to access the files on that share from your computer anytime you're on that network.

save_state=$(stty -g);echo -n "Password: ";stty -echo;read password;stty "$save_state";echo "";echo "You inserted $password as password"
2009-04-02 15:57:05
User: acirulli
Functions: stty

Allow to read password in a script without showing the password inserted by the user

find . -type f -size +25000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'
dstat -ta
read -p 'Username: ' u;sudo -H -u $u xauth add $(xauth list|grep :$(echo ${DISPLAY: -4:2}));sudo su - $u
nmap -sP your network/submask | awk "/^Host/"'{ print $2 }'
2009-04-02 12:41:54
User: rauhmaru
Functions: awk

This command will display only the hosts that are active in the network.

Ctrl+S Ctrl+Q
2009-04-02 09:27:09
User: elementa13

These are simple shortcuts to pause and continue terminal output, works in most terminals and screen multiplexers like screen. You can use it to catch something if things change too fast, and scroll with Shift + PgUp PgDown. On linux console ScrollLock can also be used.

echo $( (( $( (2**31 -1) ) - $(date +%s) )) )
2009-04-02 05:14:23
User: Chartreuse
Functions: date echo
Tags: bash echo date

Echos the number of seconds from the current time till the specified time (Example in command is (2**31-1)) aka the Unix epoch. Just replace that number with the specified date (in seconds past Jan. 1st 1970) and it will return the seconds.

NOTE: Only works in bash

true && { echo success;} || { echo failed; }
2009-04-02 01:49:25
Functions: echo true

This will perform one of two blocks of code, depending on the condition of the first. Essentially is a bash terniary operator.

To tell if a machine is up:

ping -c1 machine { echo succes;} || { echo failed; }

Because of the bash { } block operators, you can have multiple commands

ping -c1 machine && { echo success;log-timestamp.sh }|| { echo failed; email-admin.sh; }


Remember, the { } operators are treated by bash as a reserved word: as such, they need a space on either side.

If you have a command that can fail at the end of the true block, consider ending said block with 'false' to prevent accidental execution

import -pause 5 -window root desktop_screenshot.jpg
2009-04-01 22:37:33
Tags: ImageMagick

Requires ImageMagick. Takes a screenshot 5 seconds after it's run and saves it as desktop_screenshot.jpg Particularly handy when made into a menu option or button.

u=`curl -d 'dl.start=Free' $(curl $1|perl -wpi -e 's/^.*"(http:\/\/rs.*)" method.*$/$1/'|egrep '^http'|head -n1)|grep "Level(3) \#2"|perl -wpi -e 's/^.*(http:\/\/rs[^\\\\]*).*$/$1/'`;sleep 60;wget $u
while true; do ifconfig eth0 | grep "inet addr:"; sleep 60; done;
2009-04-01 19:29:28
User: bandit36
Functions: grep ifconfig sleep
Tags: script while loop

You can use this to loop any command to periodically see the output.

while true; do [YOUR COMMAND HERE]; sleep [# of seconds]; done;

Alternatively, you can put it in a simple shell script to save typing!


while true; do $1; sleep $2; done;

/path/to/script.sh "ifconfig eth0 | grep 'inet addr:'" 60