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
ffmpeg -f x11grab -r 25 -s 800x600 -i :0.0 /tmp/outputFile.mpg
2009-06-05 21:11:17
User: dcabanis
Tags: video X11 ffmpeg

Grab X11 input and create an MPEG at 25 fps with the resolution 800x600

ssh $HOST -l$USER cat /REMOTE/FILE | sdiff /LOCAL/FILE -
rsync -e 'ssh -p PORT' user@host:SRC DEST
2009-06-05 16:52:43
Functions: rsync

tested on cygwin and Fedora 9 .

good to remember for those jobs where you cannot set a site-specific connect option in your ~/.ssh/config file.

svn log -v -r{2009-05-21}:HEAD | awk '/^r[0-9]+ / {user=$3} /yms_web/ {if (user=="george") {print $2}}' | sort | uniq
2009-06-05 14:07:28
User: jemptymethod
Functions: awk sort
Tags: svn awk log

just change the date following the -r flag, and/or the user name in the user== conditional statement, and substitute yms_web with the name of your module

find ./* -ctime -1 | xargs ls -ltr --color
2009-06-05 13:53:26
User: gnuyoga
Functions: find ls xargs

added alias in ~/.bashrc

alias lf='find ./* -ctime -1 | xargs ls -ltr --color'

ifconfig eth0 down hw ether (newmacaddresshere) && ifconfig eth0 up && ifconfig eth0 (newipaddresshere) netmask up && /bin/hostname (newhostnamehere)
2009-06-04 20:25:49
User: localGhost
Functions: ifconfig

The command above has been changed due to very good constructive criticism - thanks x 2! This command can be used after acquiring mac's, ip's and hostname's or any of the above from a freshly scanned LAN. User must be root, and remember to change your settings on your network managing software manually (Fedc10 NetworkManager Applet 0.7.1 is mine) instead of 'auto DHCP'. You can also substitute eth0 for wlan0 etc - be good and ENJOY!

enscript -E --color -t "title" -w html --toc -p /PATH/to/output.html /var/log/*log
ntpdate pool.ntp.org && hwclock --systohc && hwclock --adjust
2009-06-04 13:35:14
User: Weboide
Functions: hwclock
Tags: time sync ntp clock

Do not run this command if you already have ntpd running!

This needs to run as root, for example with sudo:

sudo ntpdate pool.ntp.org && sudo hwclock --systohc && sudo hwclock --adjust

This command will fetch accurate time from NTP servers and synchronize your system clock, then it will use the system clock to synchronize your hardware clock, and will calculate the time drift.

export http_proxy=<user>:<pass>@<server>:<port> ftp_proxy=<user>:<pass>@<server>:<port>
sudo ifconfig eth0 hw ether 00:01:02:03:04:05
2009-06-04 09:02:35
User: momitov
Functions: ifconfig sudo

eth0 = the name of the interface

00:01:02:03:04:05 = the new mac adresse

the same thing for wireless card $ sudo iwconfig eth1 hw ether 00:01:02:03:04:05

recode UTF8..UTF-16LE linux-utf8-file.txt
2009-06-04 08:53:51
User: greppo

Convert file from the UTF8 encoding used on Linux (has no "EF BB BF" byte order mark at the start) to the UTF-16 encoding used on Windows (has an "FF FE" byte order mark at the start).

Thanks to commenter: previous iconv command was the obsolete way to do it.

if [ -z $(echo $var | grep [0-9]) ]; then echo "NON NUMERIC"; fi
2009-06-04 07:41:26
User: AnusJenkins
Functions: echo grep

use to execute a block of code only if $var is numeric

lshw -html > hardware.html
2009-06-04 07:14:03
User: flart

After the command is done, open the html file in a browser

find . -name "*jpg" -exec jpeginfo -c {} \; | grep -E "WARNING|ERROR"
2009-06-03 22:08:48
User: vincentp
Functions: find grep

Finds all corrupted jpeg files in current directory and its subdirectories. Displays the error or warning found.

The jpeginfo is part of the jpeginfo package in debian.

Should you wish to only get corrupted filenames, use cut to extract them :

find ./ -name *jpg -exec jpeginfo -c {} \; | grep -E "WARNING|ERROR" | cut -d " " -f 1
awk '/match/{print NR}' file
sed -n -e '1,/match/p'
URL=http://svn.example.org/project; diff -u <(TZ=UTC svn -q log -r1:HEAD $URL | grep \|) <(TZ=UTC svn log -q $URL | grep \| | sort -k3 -t \|)
2009-06-03 14:26:55
User: sunny256
Functions: diff grep sort
Tags: bash svn

Lists revisions in a Subversion repository with a timestamp that doesn't follow the revision numbering order. If everything is OK, nothing is displayed.

while (( $i != 0 )) { smbstatus; sleep 5; clear }
2009-06-03 13:26:30
Functions: clear sleep
Tags: unix samba zsh

See smbstatus Output within a 5 second interval (for monitoring smb access)

find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f
2009-06-03 09:47:08
User: mohan43u
Functions: cut file find grep sed tail xargs
Tags: tail

Works in Ubuntu, I hope it will work on all Linux machines. For Unixes, tail should be capable of handling more than one file with '-f' option.

This command line simply take log files which are text files, and not ending with a number, and it will continuously monitor those files.

Putting one alias in .profile will be more useful.

for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort -r
2009-06-03 08:25:00
User: brunost
Functions: echo head perl sort

Print out list of all branches with last commit date to the branch, including relative time since commit and color coding.

tail -f FILE | perl -pe 's/KEYWORD/\e[1;31;43m$&\e[0m/g'
2009-06-02 21:31:54
User: tuxifier
Functions: perl tail

tail with coloured output with the help of perl - need more colours? here is a colour table:


for i in `du --max-depth=1 $HOME | sort -n -r | awk '{print $1 ":" $2}'`; do size=`echo $i | awk -F: '{print $1}'`; dir=`echo $i | awk -F: '{print $NF}'`; size2=$(($size/1024)); echo "$size2 MB used by $dir"; done | head -n 10
nslookup -q=txt -class=CHAOS version.bind NS.PHX5.NEARLYFREESPEECH.NET
find /var/logs -name * | xargs tar -jcpf logs_`date +%Y-%m-%e`.tar.bz2
find ~/Desktop/ \( -regex '.*/\..*' \) -print -exec rm -Rf {} \;