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,488 results
su -c "truecrypt --non-interactive truecrypt-file cryptshare -p PASSWORD"
2009-05-22 21:11:29
User: tatwright
Functions: su

This is useful for use in scripts.

Note that this will leak your password to ps, so this shouldn't be used on shared machines. Use key files for this

scanimage -d mustek_usb --resolution 100 --mode Color > image.pnm
2009-05-22 14:00:05
User: Giancarlo
Functions: scanimage

you have to replace "mustek_usb" with the scanner found by `scanimage -l`

lame --mp3input -m m --resample 24 input.mp3
2009-05-22 13:58:03
User: Giancarlo

Useful if you have to put some mp3 files into mobile devices (ie mobile phones with no much memory)

ffmpeg -i input.flv -f mp3 -vn -acodec copy ouput.mp3
rm -rf `find -maxdepth 1 -mindepth 1 -mtime +7`
2009-05-22 11:46:57
User: tatwright
Functions: rm

This is useful for command line 'recycle bins' and such like

sudo dmidecode -t 5,16
tar -tf file.tar | tar -T - -uf file.tar
2009-05-22 00:28:13
Functions: tar

This will update the tarball, adding files that have changed since the last update.

This assumes that the tarball is in the same directory as the files being archived.

N.B. This command can't be used on compressed tarballs.

N.B. This will add the updated files to the tarball, so that the tarball will have two versions of each file. This will make the tarball larger, but doesn't have any other significant effect.

alias setvol='aumix -v'
2009-05-21 22:39:40
User: b2e
Functions: alias

If you're addicted to command-line solutions of ordinary actions or if you just want to set your volume from bed via mobile phone SSH, you can set this alias and use it as

setvol 50

for setting volume on 50% gain

Works only with ALSA, tested on Ubuntu 8.10. Give me some info about your experience.

TIP: Try aslo command "mute" to toggle mute/unmute sound. But I don't know if this works on all distros.

killall -s 9 krunner_lock
2009-05-21 22:29:06
User: b2e
Functions: killall

With this you can unlock your KDE4 session via SSH, via mobile phone SSH or e. g. scheduled task in crontab (without asking password). Useful when you need to grant somebody access to your locked profile remotely.

Create an alias (e. g. as "unlock") and use with remote KDE4 lock.

This works only on KDE4 boxes because KDE 3 is using utility with another name.

Tested on Kubuntu 8.10.

DISPLAY=:0 /usr/lib/kde4/libexec/krunner_lock --forcelock >/dev/null 2>&1 &
2009-05-21 22:19:16
User: b2e

Forgot to lock your computer? Want to lock it via SSH or mobile phone or use it for scheduled lock?

TIP: Make a alias for this (e. g. as "lock").

I found some howtos for ugly X11 lock, but this will use regular KDE locking utility.

Note that KDE 3 is using utility with another name (I guess with the same argument --forcelock)

Tested on Kubuntu 8.10.

Stay tuned for remote unlock.

F="$HOME/.moz*/fire*/*/session*.js" ; grep -Go 'entries:\[[^]]*' $F | cut -d[ -f2 | while read A ; do echo $A | sed s/url:/\n/g | tail -1 | cut -d\" -f2; done
2009-05-21 21:58:42
User: b2e
Functions: cut echo grep read sed tail

Tuned for short command line - you can set the path to sessionstore.js more reliable instead of use asterixes etc.

Usable when you are not at home and really need to get your actual opened tabs on your home computer (via SSH). I am using it from my work if I forgot to bookmark some new interesting webpage, which I have visited at home. Also other way to list tabs when your firefox has crashed (restoring of tabs doesn't work always).

This script includes also tabs which has been closed short time before.

python -c "import scapy.all; print [x[4] for x in scapy.all.conf.route.routes if x[2] != ''][0]"
ssh -C -X user@remotehost gui_command
2009-05-21 17:52:24
User: sharfah
Functions: ssh

Run GUI apps on another machine remotely through SSH.

-C is for data compression and -X enables X11 forwarding.

expr $(fdisk -s ` grep ' / ' /etc/mtab |cut -d " " -f1`) / 1024
clear; for i in `cat thehosts` ; do ssh $i "cat uname -a ; /etc/redhat-release; cat /proc/cpuinfo | tail -n 25 | egrep '^processor|^model name' "; free ; df -h ;done
curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+'
2009-05-21 16:12:21
User: haivu
Functions: grep

The curl command retrieve the HTML text containing the IP address. The grep command picks out the IP address from that HTML text.

2009-05-21 15:02:39
User: haivu
Tags: vim vi

This is a simple command for jumping to the matching brace, square bracket, or parentheses. For example, it can take you from the beginning of a function to the end with one key stroke. To delete everything between the pairs of {}, [], or (), issue the command:


To replace text between pairs of braces, brackets, or parentheses, issue the command:


You can also use this command to find out if an opening brace has been properly closed.

getconf ARG_MAX
2009-05-21 14:27:35
User: sharfah
Functions: getconf

Get max number of arguments that can be accepted by the exec() system call.

clamscan -ir --bell ~user/
2009-05-21 13:09:31

Scan for viruses, recursively and print only infected files, with bell sound. Clamscan is part of clamav package. Tested on Debian.

pstree -Gap | less -r
2009-05-21 05:15:16
User: mbirk
Functions: less
Tags: less pstree

The "pstree" command uses special line-drawing characters. However, when piped into the "less" pager, these are normally disabled.

diff <(cd dir1 && find | sort) <(cd dir2 && find | sort)
2009-05-21 04:44:29
User: mbirk
Functions: cd diff find
Tags: bash diff find

This uses Bash's "process substitution" feature to compare (using diff) the output of two different process pipelines.

grep --color=always | less -R
2009-05-20 20:30:19
User: dinomite
Functions: grep less

Get your colorized grep output in less(1). This involves two things: forcing grep to output colors even though it's not going to a terminal and telling less to handle those properly.

netstat -ntlp | grep -w 80 | awk '{print $7}' | cut -d/ -f1