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.


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:



2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.




All commands from sorted by
Terminal - All commands - 11,592 results
find /tmp -type f -printf 'rm "%p";\n'
2009-02-12 20:23:24
User: zb
Functions: find

add |sh when you agree the list, I often use that method to prevent typos in dangerous or long operations

find ./backup -type f -print0 | xargs -0 md5sum > /checksums_backup.md5
tail -f /var/log/messages
2009-02-12 19:30:33
User: nicdev
Functions: tail

Use this command to see logs update in real time

telnet <ip> <port>
2009-02-12 19:11:03
User: leprasmurf
Functions: telnet

Telnet will make a tcp connection to a remote ip/port to test connectivity. If it times out, it's not reaching the host (maybe the firewall is blocking it). If connection is refused, it's reaching the host, but either the service is not listening on that port, or it's locked.

find * -type d -exec mkdir /where/you/wantem/\{\} \;
find . -name "*.php" -exec iconv -f ISO-8859-1 -t UTF-8 {} -o ../newdir_utf8/{} \;
lsof -u www-data
usermod -a -G groupname username
find <dir> -type f -mtime +<days> -exec scp -r {} user@backuphost:/data/bkup \;
2009-02-12 07:43:29
User: rbattu
Functions: find scp

U have to make key exchange in order to avoid continuous password prompt.

ps gv [pid] | head -2
2009-02-12 05:04:55
User: ren
Functions: head ps

sh as:

#! /bin/sh

while [ 1 -ne 6 ]; do

pid=`ps -ef | grep -v "grep" | grep "trans_gzdy" | cut -c10-17`

ps gv $pid | head -2

sleep 1


check changes of RSS.

alias mute="dcop kmix Mixer0 toggleMasterMute\(\) ; dcop kmix Mixer0 masterMute\(\) | sed -e 's/true/muted/' -e 's/false/unmuted/' "
2009-02-12 04:56:33
User: wwest4
Functions: alias

arguably better than using the driver interface. lots of potentially cool stuff to be done w/ the dcop client.

>realpath ./somefile.c | xclip -selection c
2009-02-11 21:39:22
User: yalestar

Handy for those times you need to paste a file path in an IDE or some other app.

sudo apt-get install xclip

Then, for convenience, alias xclip to 'xclip -selection c' so you can just do something like realpath . | xclip

if [ ! -z "${DISPLAY}" ]; then someXcmd ; fi
2009-02-11 21:03:56
User: kmac

If you want to display a dialog (using xdialog/kdialog/zenity) you

need to make sure that you have a valid X session. Checks for

the existence of the DISPLAY variable.

nmap -sP
2009-02-11 20:44:43
User: wwest4

nmap accepts a wide variety of addressing notation, multiple targets/ranges, etc.

2009-02-11 19:34:21
User: wwest4

e.g. if rm is aliased for 'rm -i', you can escape the alias by prepending a backslash:

rm [file] # WILL prompt for confirmation per the alias

\rm [file] # will NOT prompt for confirmation per the default behavior of the command

rm -- --myfile
nmap -sT -p 80 -oG - 192.168.1.* | grep open
2009-02-11 17:47:27
User: bendavis78
Functions: grep

Change the -p argument for the port number. See "man nmap" for different ways to specify address ranges.

cat .ssh/id_rsa.pub | ssh hostname 'cat >> .ssh/authorized_keys'
2009-02-11 17:40:12
User: bendavis78
Functions: cat hostname ssh

Just run the command, type your password, and that's the last time you need to enter your password for that server.

This assumes that the server supports publickey authentication. Also, the permissions on your home dir are 755, and the permissions on your .ssh dir are 700 (local and remote).

alias dir="ls -al"
2009-02-11 16:51:01
User: katylava
Functions: alias

If you come from a DOS background and accidentally use DOS commands often, this and others like it can be helpful. Add to your .bash_profile, or wherever you keep such things.

svn st | grep /main/java | awk '{print $2}' | xargs echo | xargs svn ci -m "my comment here"
alt + .
2009-02-11 15:26:34
User: vbs100

Insert the last argument to the previous command

for ip in $(seq 1 25); do ping -c 1 192.168.0.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.0.$ip UP" || : ; done
2009-02-11 14:57:34
Functions: echo ping seq

this is very useful when there is a different network host to determine which are turned on or not

xrandr --output LVDS --auto --output VGA --auto --right-of LVDS
2009-02-11 13:20:17
User: root

You'll need to make sure your xorg.conf permits a virtual screen size this big. If it doesn't then xrandr should return a suitable error message that tells you the required size.

history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
rar a -m0 "${PWD##*/}.rar" *
2009-02-11 13:06:34

This command creates a rar archive from all files in the current folder and names the archive after the folder name.