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:



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.

Top Tags



All commands from sorted by
Terminal - All commands - 12,075 results
find . -type f -name "*\?*" | while read f;do mv "$f" "${f//[^0-9A-Za-z.\/\(\)\ ]/_}";done
2014-11-28 14:55:27
User: miccaman
Functions: find mv read
Tags: bash find mv

replace all "?" characters in filename to underscore

find . -type d -name "*\?*" | while read f;do mv "$f" "${f//[^0-9A-Za-z.\/\(\)\ ]/_}";done
2014-11-28 14:52:46
User: miccaman
Functions: find mv read
Tags: bash find mv

rename all dirs with "?" char in name, leave spaces and () in place

( ps -U nms -o pid,nlwp,cmd:500 | sort -n -k2) && (ps h -U nms -o nlwp | paste -sd+ | bc)
ps axo pid=,stat= | awk '$2~/^Z/ { print $1 }'
2014-11-26 21:29:33
User: krizzo
Functions: awk ps

This prints out a list of all zombie processes PIDs so you can do things like kill the zombies

speakwhenup() { [ "$1" ] && PHOST="$1" || return 1; until ping -c1 -W2 $PHOST >/dev/null 2>&1; do sleep 5s; done; espeak "$PHOST is up" >/dev/null 2>&1; }
2014-11-26 10:22:18
User: aguslr
Functions: ping return sleep
Tags: ping beep espeak

This allows for sleeping in between pings. Also, espeak needs to be installed.

sed -i 's/geteuid/getppid/g' /usr/bin/vlc
2014-11-21 17:43:59
User: nadavkav
Functions: sed
Tags: root vlc

Enable root user to run VLC

isKsh () { one=1; [ one -eq 1 ] 2> /dev/null; }
2014-11-18 20:45:12
User: applemcg

Dave Korn gave me this one. It works because ksh allows variable names ( w/o the $name syntax ) used by sh and bash.

I wrote it to permit "single source" shell libraries; the current objective: every shell library may be sourced by either shell. see http://github.com/applemcg/backash

touch -t 197001010000 ./tmp && find . -newer ./tmp && rm -f ./tmp
2014-11-18 00:29:26
User: sergeylukin
Functions: find rm touch

Sometimes you just want to operate on files that were created after specific date. This command consists of 3 commands:

- Create a dummy file with the custom date

- Find all files with "creation time" further than our custom date by using `-newer` find option. Add your crazy stuff here, like moving, deleting, printing, etc.

- Remove the dummy file

locate -0 -i *barthes* | xargs -0 mv -t ~/'Library/Books/Barthes, Roland'
2014-11-16 18:26:35
User: qdrizh
Functions: locate mv xargs
Tags: mv xargs locate

Find all books on my systems and move them into folder. The -0 switches are to handle spaces etc. in the filenames.

Why would you need this? Locate uses an index, so it's super quick, and xargs is more elegant than a for loop.

python -c "import pip; print(' '.join([x.project_name for x in pip.get_installed_distributions()]))" | xargs sudo pip install -U
brew outdated | cut -f1 | xargs brew upgrade
2014-11-16 09:51:50
User: wires
Functions: cut xargs

You probably want to run `brew update` before you run this command

find . -name "*.pdf" -exec pdftk {} dump_data output \; | grep NumberOfPages | awk '{print $1,$2}'
2014-11-14 23:36:56
User: mtrgrrl
Functions: awk find grep

using awk, changed the line given by sucotronic in command #11733 to print the first and second columns

find ./i18n -name "*.po" | while read f; do msgfmt $f -o ${f%.po}.mo; done
2014-11-14 19:14:35
User: sergeylukin
Functions: find read

This command takes all `.po` files inside `i18n` directory and compiles them to `.mo` files with same basename

lxshortcut -o ~/Desktop/myLauncher
PID=$(ps -ef | grep processName | grep -v grep | awk '{print $2'}); kill -9 $PID
pm2 start app.js
2014-11-07 23:15:12
User: strzel_a

I'm the author of PM2 and wrote this tool, and I'm please to share it here.

Github project link: https://github.com/Unitech/pm2

nmap -sP
curl -s -o /dev/null -w "%{http_code}\n" localhost
curl --write-out %{http_code} --silent --output /dev/null localhost
mencoder -speed 2 -o output.avi -ovc lavc -oac mp3lame input.avi
starts a CGI web server
2014-11-05 23:07:37
User: andreisid

In case you need to test some CGI scripts this does the job. It also has the functionality of a http server.


grep VmHWM /proc/$(pgrep -d '/status /proc/' FOO)/status
2014-11-05 15:06:29
User: michelsberg
Functions: grep

Show the maximum amount of memory that was needed by a process at any time. My use case: Having a long-running computation job on $BIG_COMPUTER and judging whether it will also run on $SMALL_COMPUTER.


VmHWM: Peak resident set size ("high water mark")

chmod +x myfile.py
export PATH=$PATH:/home/user/my_prog
grep 'font-family:[^;]*' <input file.svg> | sed 's/.*font-family:\([^;]*\).*/\1/g' | sort | uniq
2014-11-03 20:38:08
User: caiosba
Functions: grep sed sort
Tags: fonts svg

List all fonts used by an SVG file. Useful to find out which fonts you need to have installed in order to open/edit an SVG file appropriately.