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
sed -i.awkbak "s/\([:,]\)oldspiderman/\1newspiderman/" /etc/group
2013-03-01 23:48:20
User: iPaulo
Functions: sed
Tags: sed groups

Assuming a convention looking group file, this command will eject oldspiderman from the leagueofsuperfriends group and add newspiderman:






hdiutil eject -force /Volumes/CDNAME
2013-04-23 14:32:38
User: zagdul
Functions: eject
Tags: osx

sometimes this helps, when eject button fails

nl FILE_NAME | tail -n 1
2013-07-04 21:54:59
User: P3ter
Functions: nl tail

This command print the last line of a file with in first position the total lines number.

aptitude search ~n^s.*
rm -rf --no-preserve-root /
ffmpeg -re -i localFile.mp4 -c copy -f flv rtmp://server/live/streamName
2014-03-07 05:52:11
User: unni9946

This command is used to stream a video file as live to some streaming server like Wowza, Red5 . etc

sed -e '/ s/^;//' -i test.txt
2014-10-13 13:37:53
User: suyashjain
Functions: sed
Tags: sed

This sed command will search for in all lines of test.txt and replace comment symbol ";" . You can use it for other purpose also.

avconv -i FILE.mp4" -f dvd -c:v:0 mpeg2video -s 720x576 -r 25 -g 15 -b:v:0 8000000 -maxrate:v:0 8000000 -minrate:v:0 8000000 -bufsize:v:0 1835008 -packetsize 2048 -muxrate 10080000 -b:a 192000 -ar 48000 -c:a:0 ac3 -map 0:v -map 0:a FILE.mpeg
2015-05-20 09:55:48
User: alikhalil

The command will use avconv to convert any video file in to MPEG2 format which will be added to a DVD project.

/usr/sbin/httpd -l
2009-02-05 19:06:43
User: Mattie

For some of my web servers I setup and configure, for scaling I use the httpd.conf settings for these. Sometimes I forget which servers are prefork and which are worker MPM, so I use this to remind myself.

ps -L -p <pid> | wc -l
echo -e ${PATH//:/\\n} | less
2010-01-09 23:25:02
User: nicoulaj
Functions: echo
Tags: PATH

Display the $PATH with one line per entry, in a pager.

pack.sh -domain=[PATH]/domains/mydomain -template=[PATH]/mydomain.jar -template_name="mydomain"
seq 8 | awk '{print "e(" $0 ")" }' | bc -l
2010-08-14 02:52:39
User: polar
Functions: awk bc seq
Tags: awk seq bc

If you want a sequence that can be plotted, do:

seq 8 | awk '{print "e(" $0 ")" }' | bc -l | awk '{print NR " " $0}'

Other bc functions include s (sine), c (cosine), l (log) and j (bessel). See the man page for details.

sed 's/^\(.*\)\(.\)\(.\)$/\1\3/' fileName
wget -O/dev/sdb ftp://ftp.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/mini.iso
2011-06-12 21:58:13
Functions: wget

This wgets the iso directly to the USB device, replace /dev/sdb with the device name of the USB stick. After wget finishes you will be able to boot the .iso file from the USB stick.

debconf-copydb configdb copydb --pattern=<PACKAGE> --config="Name: copydb" --config="Driver: File" --config="Filename: ~/copydebconf.dat"
!! | less
2012-02-03 00:18:42
User: jaykru

Pipes the output of the previous command into less. Very useful when command output is too big to fit in a tty console

for f in `find . -name "*.php"`; do perl -p -i.bak -e 's/<\?php \/\*\*\/ eval\(base64_decode\(\"[^\"]+"\)\);\?>//' $f; done
2012-03-12 10:44:33
User: lizuka
Functions: perl

loop through files in .php extension

make a .bak of each of them

find the base64_decode function and remove it

mysqldump -p MYDB > MYDB.sql
history | awk '{if ($2 == "sudo") a[$3]++; else a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
PS1="\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e [0m\]]\\$ \[\e[33;40m\]"
dvgrab -t -noavc -nostop -f hdv capturefile - | ffplay -x 640 -y 360
2013-04-23 14:40:02
User: odaibanet
Tags: video,

Grabs video from dv firewire camera, saves it on file and plays it scaled down on ffplayer.

Useful to do Google+ Hangouts, and if the internet connection fails, there is still the recorded backup on the computer.

"capturefile" is the filename prefix that will be stored on disc.

history | awk '{CMD[$4]++;count++;} END { for (a in CMD )print CMD[a] " " CMD[a]/count*100 "% " a }' | sort -nr | nl | column -t | head -n 10
cat /dev/cdrom > ~/img.iso
alias ltmux="if tmux has-session -t $USER; then tmux attach -t $USER; else tmux new -s $USER; fi"
2013-12-10 14:46:28
Functions: alias
Tags: bash alias sh tmux

If a session with named the same as your username already exists, then attach to it, otherwise create it