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,230 results
ldd file | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /destination
2012-02-11 17:50:10
User: rickard2
Functions: awk cp file grep ldd xargs

When working with jailed environments you need to copy all the shared libraries to your jail environment. This is done by running ldd on a binary which needs to run inside the jail. This command will use the output from ldd to automatically copy the shared libraries to a folder of your choice.

git diff | git apply --reverse
feh --bg-scale "`ls -d $HOME/backgrounds/* |sort -R |tail -1`"
2013-03-16 16:05:48
User: bertatum

Change your Desktop background/wallpaper with feh lightweight command.

fill background directory with appropriate content.

echo c > /proc/sysrq-trigger
2013-05-07 19:41:40
User: fangfufu
Functions: echo
Tags: kernel

Well, this is quite useful for testing if your hardware watchdog is working properly.

convert yourdoublewideimage.jpg -crop 50%x100% +repage output.jpg
2014-01-15 15:34:41
User: pagesix1536

Output should be two JPG files named like "output-1.jpg" and "output-2.jpg". The convert command is part of ImageMagick so you'll need that and dependent packages installed to use it.

git commit --allow-empty-message --message ""
2014-07-16 02:06:39

This is especially useful for adding changes to a temporary repo, such as a Gist. Avoid using this when collaborating with others.

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

(acroread &);sleep 2;gdb /opt/Adobe/Reader8/Reader/intellinux/bin/acroread `pidof ld-linux.so.2`
echo 2+3 |bc
2009-07-04 22:03:41
User: Kaio
Functions: echo

Handy use of bc in the command line. No need to get 'into' the bc to perform calculations

perl -ne '$pkg=$1 if m/^Package: (.*)/; print "$1\t$pkg\n" if m/^Installed-Size: (.*)/;' < /var/lib/dpkg/status | sort -rn | less
2009-10-19 12:55:59
User: hfs
Functions: perl sort

List packages and their disk usage in decreasing order. This uses the "Installed-Size" from the package metadata. It may differ from the actual used space, because e.g. data files (think of databases) or log files may take additional space.

type <command>
find . -name "*.php" -exec grep -i -H "search pharse" {} \;
awk '{if ($1~/Sun|Mon|Tue|Wed|Thu|Fri|Sat/) {DATE=$2" "$3" "$4" "$5 } else {print DATE"|"$0}}' alterorcl.log
sudo netstat|head -n2|tail -n1 && sudo netstat -a|grep udp && echo && sudo netstat|head -n2|tail -n1 && sudo netstat -a|grep tcp
echo foobar | sed -r 's/(^.|.$)//g'
(sed 's/^/x*=/' file ; echo x) | bc
DATE=`date +"%H:%M" --date '-1 min'`; egrep "\ $DATE\:..\ " /var/log/dhcpd.log |awk '/DHCPREQUEST/ {split($3,t,":"); printf("%02d:%02d\n",t[1],t[2]);}' |uniq -c;
hexdump -C file
(date "+%d-%m-%Y %H:%M:%S";curl -s --interface lo:1 ifconfig.me| xargs -t geoiplookup 2>&1)|sed -e 's/geoiplookup/IP:/g' -e 's/GeoIP Country Edition/Country/g'|tr -s "\n" " "|sed 'a\ '
2013-10-07 15:28:55
User: guerito
Functions: date sed tr xargs

My first command :) I made this command to log public addresses of a virtual interface who connects random VPN servers around the world.

command_line 2>&1 | tee -a output_file
git log --graph --decorate --pretty=oneline --abbrev-commit
for f in input/*; do BN=$(basename "$f"); ffmpeg -i "$f" -vn "temp/$BN.flac"...
2015-03-01 02:48:19
Functions: basename

Full command:

for f in input/*; do BN=$(basename "$f"); ffmpeg -i "$f" -vn "temp/$BN.flac"; sox "temp/$BN.flac" "temp/$BN-cleaned.flac" noisered profile 0.3; ffmpeg -i "$f" -vcodec copy -an "temp/$BN-na.mp4"; ffmpeg -i "temp/$BN-na.mp4" -i "temp/$BN-cleaned.flac" "output/$BN"; done

This was over the 255 character limit and I didn't feel like deliberately obfuscating it.

1. Create 'input', 'output' and 'temp' directories.

2. Place the files that you want to remove the hiss/static/general noise from in the input directory.

3. Generate a noise reduction profile with sox using 'sox an_input_file.mp4 -n trim x y noiseprof profile', where x and y indicates a range in seconds that only the sound you want to eliminate is present in.

4. Run the command.

files=(/usr/share/cowsay/cows/*); cowsay -f `echo ${files[$((RANDOM%${#files}))]}` `fortune` | toilet -F gay -f term
2011-02-20 05:55:33
User: lkjoel

This command will tell you your fortune, with a nice Ascii Art animal, and it is colorized

You need cowsay, toilet and fortune installed.

On Ubuntu this is:

sudo apt-get install cowsay toilet fortune


aptitude install cowsay toilet fortune
#!/bin/bash find | grep -P -v "(class)|(zip)|(png)|(gz)|(gif)|(jpeg)|(jpg)" | xargs -I @ grep -H $1 @
2011-10-14 13:28:49
User: kirdie
Functions: find grep xargs
Tags: find grep

calls grep on all non-binary files returned by find on its current working directory

if [[ $EUID -ne 0 ]]; then echo 'Root permissions required! Exiting.'; exit; fi
2011-11-19 23:06:52
User: lordtoran
Functions: echo

This example code is intended to be used as a root permissions check in a script. It makes use of the $EUID (effective user ID) environment variable which is fully su- and sudo-safe.