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,364 results
sudo strace -e trace=network -p `pidof nginx | sed -e 's/ /,/g'`
2016-01-28 18:48:16
Functions: sed strace sudo

Nginx (and other webservers like Apache) can be awkward to trace. They run as root, then switch to another user once they're ready to serve web pages. They also have a "master" process and multiple worker processes.

The given command finds the process IDs of all Nginx processes, joins them together with a comma, then traces all of them at once with "sudo strace." System trace output can be overwhelming, so we only capture "networking" output.

TIP: to kill this complex strace, do "sudo killall strace".

Compare with a similar command: http://www.commandlinefu.com/commands/view/11918/easily-strace-all-your-apache-processes

pacman -Ss python | paste - - | grep --color=always -e '/python' | less -R
2016-01-25 14:29:31
User: hute37
Functions: grep less paste python
Tags: less paste pacman

Alternative1 (grep support):

pacman -Ss python | paste - - | grep --color=always -e '/python' | less -R

Alternative2 (eye-candy, no grep):

pacman --color=always -Ss "python" | paste - - | less -R

in ~/.bashrc:

pkg-grep() { pacman -Ss "$1" | paste - - | grep --color=always -e "${2:-$1}" | less -R ; }

pkg-search() { pacman --color=always -Ss "python" | paste - - | less -R; }

ps -eo pmem,comm | grep chrome | cut -d " " -f 2 | paste -sd+ | bc
echo one 22 three | awk -F'[0-9][0-9]' '{print $2}'
get_iplayer --type=radio --channel "Radio 4 Extra" | grep : | awk '{ if ( NR > 1 ) { print } }'|sed 's/:.*//' |sed '$ d' > pidlist && while read p; do get_iplayer --get --fields=pid $p; done <pidlist && rm pidlist
2016-01-16 17:20:54
User: dunryc
Functions: awk grep read rm sed

use get_iplay to download all listed content from http://www.bbc.co.uk/radio4extra run every night to make sure no episodes are missed

openssl enc -d -aes-256-cbc -a -in bitcoin-wallet-backup -out bitcoin-wallet-backup-decrypted
stat -f '%Su' /dev/console
declare -a array=($(tail -n +2 /proc/net/tcp | cut -d":" -f"3"|cut -d" " -f"1")) && for port in ${array[@]}; do echo $((0x$port)); done
ffmpeg -loop 1 -i image.jpg -i audio.m4a -c:v libx264 -c:a aac -strict experimental -b:a 192k -vf scale=720:-1 -shortest video-output.mp4
[email protected]; tar -cf - /path/to/dir | pv | nc -l -p 6666 -q 5; [email protected]; nc 6666 | pv | tar -xf -
sajb {$ip="";$old=0;while(1){$up=test-connection -quiet -count 1 $ip;if($up-ne$old){$s=(date -u %s).split('.')[0]+' '+(date -f s).replace('T',' ')+' '+$ip+' '+$(if($up){'Up'}else{'Down'});echo $s|out-file -a $home\ping.txt;$old=$up}sleep 10}}

IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type


Uses sajb to start a PowerShell background job that pings an IP host every 10 seconds.

Any changes in the host's Up/Down state is time-stamped and logged to a file.

Date/time stamps are logged in two formats: Unix and human-readable.

A while(1) loop repeats the test every 10 seconds by using the sleep command.

See the Sample Output for more detail.

I use this command to log Up/Down events of my Motorola SB6141 cable modem (

To end the logging, close the PowerShell window or use the "exit" command.

while(1){while((date -f ss)%10-gt0){sleep -m 300} echo "$(date -u %s) $((curl|%{$_ -replace '\D+\n',''})">>modemlog.txt;sleep 1;echo .}
2015-12-24 02:12:10
User: omap7777
Functions: date echo sleep

IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type


Create a log file of your Motorola Surfboard SB6141 downstream signal strengths.

Uses the built-in curl to request signal strength data from your SB6141 cable modem.

HTML page has the signal strength numbers for the 8 downstreams.

Some HTML/DOM processing parses out the 8 values from the above page.

The eight extracted signal strengths are then logged to a file.

A small while-loop watches the clock & repeats the process every 10 seconds.

rsync -a --progress -e 'ssh -p 2200 -i .vagrant/machines/default/virtualbox/private_key' [email protected]:/vagrant/vm/old_timecapsule_backup /Volumes/2TB/
2015-12-17 15:28:12
User: brainstorm
Functions: rsync

That is, after running `vagrant ssh-config` to determine ports and ip's:

vagrant ssh-config

Host default


User vagrant

Port 2200

UserKnownHostsFile /dev/null

StrictHostKeyChecking no

PasswordAuthentication no

IdentityFile /Users/romanvg/tmp/.vagrant/machines/default/virtualbox/private_key

IdentitiesOnly yes

LogLevel FATAL

for f in `git status | grep new | awk '{print $3}'`; do git reset HEAD $f ; done
lc() { od="$1"; nd="$2"; of=$3; nf=$4; cp -rl "$od" "$nd"; find $nd -type f -iname \*$of -print -execdir ffmpeg -i {} -loglevel error -q:a 6 {}.$nf \; -execdir rm {} +; find $nd -type f -iname \*.$of.$nf -execdir rename "s/$of.$nf/$nf/" {} +; }
2015-12-16 20:16:01
User: snipertyler
Functions: cp find rename rm

Music Library Convert


lc Old_Directory New_DIrectory Old_Format New_Format

lc ~/Music ~/Music_ogg mp3 ogg

This will convert all audio files in the old directory to the new directory from the old format to the new format. It will leave the original library alone. The converted library will retain folder structure.

s3cmd du s3://bucket-name | awk '{print $0/1024/1024/1024" GB"}'
jmap -dump:live,format=b,file=o.hprof pid ; jstack -l pid > /oracle/ora_app1/p.tdump
cat < /dev/tcp/
docker inspect --format "{{ .Name }} # {{ .NetworkSettings.IPAddress }} # {{ .NetworkSettings.Ports }}" $(docker ps -q) | tr -s '#' '\t'
while true; do printf "\e[38;5;$(($(od -d -N 2 -A n /dev/urandom)%$(tput colors)))m.\e[0m"; done
2015-11-24 15:21:27
User: atoponce
Functions: printf
Tags: urandom

Looks best in an 80x24 256-color terminal emulator.

git log --oneline | nl -v0 | sed 's/^ \+/&HEAD~/'
2015-11-23 21:35:57
User: flatcap
Functions: nl sed
Tags: git sed nl git-log

Print a git log (in reverse order) giving a reference relative to HEAD.

HEAD (the current revision) can also be referred to as HEAD~0

The previous revision is HEAD~1 then HEAD~2 etc.


Add line numbers to the git output, starting at zero:

... | nl -v0 | ...


Insert the string 'HEAD~' before the number using sed:

... | sed 's/^ \+/&HEAD~/'


Thanks to bartonski for the idea :-)

o=0; git log --oneline | while read l; do printf "%+9s %s\n" "HEAD~${o}" "$l"; o=$(($o+1)); done | less
pdf2txt myfile.pdf | grep mypattern
2015-11-23 17:46:22
User: grinob
Functions: grep
Tags: pipe grep pdf

This is a good alternative to pdf2text for Ubuntu. To install it:

sudo apt-get install python-pdfminer

SRC="/source/folder"; TRG="/target/folder/"; tar cf - "$SRC" | pv -s $(du -sb "$SRC" | cut -f1) | tar xf - -C "$TRG"
dockexecl() { docker exec -i -t $(docker ps -l -q) bash ;}