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.

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



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

All commands from sorted by
Terminal - All commands - 12,388 results
avconv -i input.avi -target pal-dvd dvd.mpg && echo PAL > ~/.config/video_format && dvdauthor -o dvd/ -t dvd.mpg && dvdauthor -o dvd/ -T && growisofs -Z /dev/dvd -dvd-video dvd/
2012-09-09 20:56:54
User: ppq
Functions: echo

This is the fastest way to burn a DVD-Video from the command line.





The first command:

avconv -i input.avi -target pal-dvd dvd.mpg

converts any given video file avconv can handle into MPEG2-PS (6 Mbit/s) with AC3 audio (448 kbit/s). If your distribution is not up to date, just use ffmpeg - the syntax is the same. Hint: If you want to create an NTSC DVD, type ntsc-dvd instead ;-)

The second command:

echo PAL > ~/.config/video_format

sets PAL as your default video format. This is a workaround for an old dvdauthor bug. If you want NTSC, guess what? Type NTSC instead!

The third command:

dvdauthor -o dvd/ -t dvd.mpg

creates .VOB files and adds them to the dvd/ folder. You don't have to create this folder yourself. You can add as many titles as you like, just keep in mind that there's a maximum of 4482 MiB (4.37 GiB) for normal DVDs.

The fourth command:

dvdauthor -o dvd/ -T

finishes the DVD-Video.

Now you can burn your DVD using growisofs:

growisofs -Z /dev/dvd -dvd-video dvd/




find /var/scripts -name 'backup*' -exec {} ';'
2013-07-24 21:25:21
User: piscue
Functions: find
Tags: backup

It eases the way of creating cron jobs of backup scripts.

Just put this line as cron job, and all your backups are called sequentially.

Allows you to forget, when in time, call this backup, just focus on your scripting. Also maintains the way of calling a single backup script when It's needed.

find . -name "*.php" -exec php -l {} \; | grep found
2014-07-11 14:17:34
User: azizsaleh
Functions: find grep

Same but will only returns the invalid file (great when emailing the list to the team).

find . -type f -exec grep -l pattern {} \; | xargs vi +/pattern
syslog -F '$Time $Message' -k Sender /System/Library/CoreServices/backupd -k Time ge -72h | tail -n 30
2009-02-19 04:33:25
User: sacrilicious
Functions: tail

While they are few config options and even fewer useful details regarding what actually is being sent by the time machine 'backupd' process, this can at least tell you its doing something, how much it's doing, and exactly how often. Via macosxhints, http://xrl.us/begrwa, which in turn was via comments

svn rm `svn status | grep "\!" | cut -c 8-`
2009-03-29 13:28:55
User: benschw
Functions: cut grep rm
Tags: svn

If (when) you forget to "svn rm" files from your repository, use this to let your repository know you want those files gone. Of course this works with adding and reverting too.

grep '\<110/' /etc/services; grep '\b110/' /etc/services
2010-11-25 08:29:42
User: unefunge
Functions: grep
Tags: grep services

I used 110 as the port number in examples for clarity.

backslash+lessthan or backslash+b marks 'edge of the word'.

jhead -autorot *

Digital cameras embed EXIF data into the images they create indicating which orientation the photo was taken in. Some viewers and editors are smart enough to read this, but many are not (and web browsers ignore it). jhead is one of not many tools available that can losslessly rotate jpeg images. This command reads the EXIF orientation of each image, and rotates it if necessary.

TZ=$TZ-72 date +%d.%m.%Y
ping1 IPaddr_or_hostname
2012-02-09 17:26:32
User: waibati
Tags: echo IP ping

export THISOS="`uname -s`"

if [ "$THISOS" = "SunOS" ]


export THISRELEASE="`uname -r`"

ping1() { ping -s $1 56 1 | egrep "^64"; }

elif [ "$THISOS" = "AIX" ]


export THISRELEASE="`uname -v`.`uname -r`"

ping1() { ping -w ${2:-1} $1 56 1 | egrep "^64"; }

elif [ "$THISOS" = "Linux" ]


export THISRELEASE="`uname -r`"

ping1() { ping -c 1 -w ${2:-1} $1 | egrep "^64"; }


svnll(){svn log "$@"|( read; while true; do read h||break; read; m=""; while read l; do echo "$l" | grep -q '^[-]\+$'&&break; [ -z "$m" ] && m=$l; done; echo "$h % $m" | sed 's#\(.*\) | \(.*\) | \([-0-9 :]\{16\}\).* % \(.*\)#\1 \2 (\3) \4#'; done)}
2012-03-25 20:39:05
User: vhotspur
Functions: echo grep read sed
Tags: log subversion

Emulate (more or less) Git equivalent of

git log --format='tformat:%h %an (%cr) %s'
goWall() { if [ $# -ne 1 ]; then echo 'goWall image';return;fi;w=w.jpg;o="$1";f="$1"-f;of="$1"-af;off="$1"-aff;convert "$1" -flop $f;montage -geometry +0+0 -tile 2x "$1" $f $of;convert $of -flip $off;montage -geometry +0+0 -tile 1x $of $off $w }
2012-07-17 05:01:58
User: meathive
Functions: echo

This command clones an image three times and creates a 'tile' image that can be used for a repeating pattern wallpaper. Add 'rm $f $of $off' to the end for cleanup (command was too long to submit with it).

See this link for an example: http://meathive.deviantart.com/art/Easy-Photography-Hack-314846774

lynx -useragent=Opera -dump 'http://www.facebook.com/ajax/typeahead_friends.php?u=100000475200812&__a=1' |gawk -F'\"t\":\"' -v RS='\",' 'RT{print $NF}' |grep -v '\"n\":\"' |cut -d, -f2
jockey-text -l
hdparm -y /dev/sda
file -i * | grep 'text/plain' | wc -l
2009-08-16 21:22:46
User: voyeg3r
Functions: file grep wc

get files without extensions, get ASCII and utf-8 as "text/plain"

utime(){ awk -v d=$1 'BEGIN{print strftime("%a %b %d %H:%M:%S %Y", d)}'; }
pkill <process name>
ssh [email protected] "PGPASSWORD='passwd' pg_dump -U user bd_name | bzip2 -zv9" | bzcat | psql -U user bd_name
scrot $1 /tmp/screenshot.png && curl -s -F file1=@/tmp/screenshot.png -F submit="OMPLOAD\!" http://ompldr.org/upload | egrep '(View file: <a href="v([A-Za-z0-9+\/]+)">)' | sed 's/^.*\(http:\/\/.*\)<.*$/\1/' | xsel -b -i ? (full in a sample output)
ffmpeg -f video4linux2 -s 320x240 -i /dev/video0 -f alsa -ac 1 -i default -f mp4 Filename.mp4
2011-08-01 08:58:17
User: lugoteehalt

May need to use pavucontrol to set sound to correct things, use when ffmpeg is running.

echo `wget -q -O - http://www.whatismyip.org`
find . -name ._\* -exec rm -f {} \;
2012-05-14 22:25:42
User: silicontrip
Functions: find rm
Tags: find rm

This command won't delete resource forks from an HFS file system, only from file systems that don't natively support resource forks.

find . -type f \( -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.cxx' \) | xargs grep "#include.*\.c.*" 2>&1 | tee source_inside_source_list.txt