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,273 results
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 user@remoteserver "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
lynx -useragent=Opera -dump 'http://www.facebook.com/ajax/typeahead_friends.php?u=4&__a=1' |gawk -F'\"t\":\"' -v RS='\",' 'RT{print $NF}' |grep -v '\"n\":\"' |cut -d, -f2
hdparm -S5 /dev/sda
curl -s www.google.com/ig/api?weather=$(curl -s api.hostip.info/get_html.php?ip=$(curl -s icanhazip.com) | sed -e'1d;3d' -e's/C.*: \(.*\)/\1/' -e's/ /%20/g' -e"s/'/%27/g") | sed 's|.*<t.*f data="\([^"]*\)"/>.*|\1\n|'
2010-02-14 19:44:54
User: o0110o
Functions: sed

Check your local temperature based on geolocation.

x="1" && z="`ls -l * | wc -l`"; for y in *.mp3; do `id3v2 --TRCK "$x/$z" "$y"`; x=$[$x+1]; done
2011-11-17 18:52:59
User: robotmachine
Tags: Linux mp3 id3

Assumes that the files are named in numerical order (ie. 01 Filename.mp3). It will set the track number as tracknumber/totaltracks (ie. 1/14). This will write both ID3v1 and ID3v2 tags.

Note: This only writes the track numbers.

for i in `cat /proc/cpuinfo |grep processor|awk '{print $3}'`;do cpufreq-set -g ondemand $i;done
2011-12-31 01:44:18
User: godmachine81
Functions: awk grep

Save as a bash script and run as root to set the ondemand cpu frequency governor for all cpu cores. Name the file ondemand. Change 'ondemand' in the argument to performance or your preferred governor to do the same thing but set all cpu cores to use the performance governor (or your preferred governor)

find . -ls | sort -k 7 -n
pacmd set-sink-volume 0 0x10000
2012-07-17 15:02:56
User: andycandet

This command sets the volume for the main PulseAudio "sink" (usually the ALSA output interface) to the maximum, 100% (the 0x10000 in the command). To set it to an arbitrary volume, replace 10000 with the volume you want times 100 (so 75% becomes 7500).

lynx -useragent=Opera -dump 'http://www.facebook.com/ajax/typeahead_friends.php?u=521826202&__a=1' |gawk -F'\"t\":\"' -v RS='\",' 'RT{print $NF}' |grep -v '\"n\":\"' |cut -d, -f2
for file in `ls -t \`find . -name "*.zip" -type f\``; do found=`unzip -c "$file" | grep --color=always "PATTERN"`; if [[ $found ]]; then echo -e "${file}\n${found}\n"; fi done
2012-11-12 15:43:15
User: vladfr
Functions: echo file grep

for file in `ls -t \`find . -name "*.zip" -type f\``; do

found=`unzip -c "$file" | grep --color=always "PATTERN"`;

if [[ $found ]]; then echo -e "${file}\n${found}\n"; fi


curl 'AudioStream' | ffmpeg -i - -acodec libvorbis file.ogg
2014-03-31 02:07:20
User: snipertyler

This encodes it in ogg format.

Does on-the-fly encoding of the incoming stream.

Great for radio streams as they're often flv format.

postqueue -p | grep -A 1 "over quota" | grep @ | sort | uniq | tr --delete ' '
svn status | grep '^\?' | sed -e 's/^\?//g' | xargs svn add
2009-02-28 03:00:28
User: dollyaswin
Functions: grep sed xargs

These part of the command:

svn status | grep '^\?' => find new file or directory on working copy

sed -e 's/^\?//g' => remove "^" character on the first character of file name

xargs svn add => add file to subversion repository

You can modify above command to other circumtances, like revert addition files or commit files that have been modified. ^_^