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
echo -e "n\np\n1\n\n\nt\n8e\nw" | fdisk /dev/sdX
2009-10-20 16:21:54
User: sud0er
Functions: echo fdisk
Tags: Linux fdisk

This is a bit hacky, but if you're setting up a bunch of new LUNs, it can save a bunch of time. Also check out sfdisk. The fdisk will fail if, for example, a partition table already exists.

mknod replypipe p; nc -k -lp 1234 < replypipe| nc -U /var/run/mysocket.sock > replypipe
2014-07-19 18:17:35
User: adimania
Functions: mknod

* Make a FIFO file named replypipe

* listen on 1234

* pass the request to unix socket

* unix socket will reply to replypipe

* replypipe will write reply to the client

gsed -e :a -e 's/\(<\/[^>]*>\)/\1\n/g;s/\(<br>\)/\1\n/g' page2.txt | sed -n '/<cite>/p;s/<cite>\(.*\)<\/cite>/\1/g' >> output
2009-02-06 12:45:20
User: shrimphead
Functions: sed

From a saved page of google search results, split out all of the links for the results. Useful for creating apache rewrite rules from.

java -jar /path/to/filename.jar
2011-04-01 05:44:56
User: Bonster

Use this to make a launcher for Java apps ( .jar files ) such as with jdownloader

ls -1 | xargs ruby -e'puts ARGV.shuffle'
perl -le 'print join ", ", map { chomp; $_ } <>'
2009-02-06 12:50:43
User: jozef
Functions: join perl

joins multiple lines to create single line with comma separated values. for example if we have an email addresses one per line (copy&paste from spreadsheet) it will oputput one line with comman separated addresses to put it to email client.

dhclient wlan0 && sbnt=$(ifconfig wlan0 |grep "inet addr" |cut -d ":" -f 2 | cut -d "." -f 1-3) && nmap $sbnt.0/24 -sP
2010-06-22 21:00:29
User: wltj
Functions: cut grep ifconfig

This is helpful if you connect to several networks with different subnets such as 192 networks, 10 networks, etc. Cuts first three octets of ip from ifconfig command and runs nmap ping scan on that subnet.

Replace wlan0 with your interface. Assumes class c network, if class b use: cut -d "." -f 1-2 and change nmap command accordingly.

lynx --dump http://www.seeon.tv/channels| grep "/channels"|awk '{print $2}'|sort -u|while read links; do lynx --dump "$links"|awk '/view/ {print $2}'|sort -u; done
2011-04-01 05:58:20
User: Bonster
Functions: awk grep read sort

This shows a list of channels from seeon.tv website to watch shows and movies

du -ks * | sort -n
2009-02-16 14:18:52
Functions: du sort

Very useful for finding the largest files and subdirectories at any given point. Any user can run it from current location just when need to know their largest files and subtdirectories from a certain point down as well.

sudo chown -R user2:user2 /../../somedirectory
2009-09-23 21:27:45
User: bkn390
Functions: chown sudo

This will change the ownership of /../../somedirectory as well as all its subdirectories so they will be be owned by user2 - typically used when a directory is owned by root:root

< <infile> tr ' \t' '\n' | tr -s '\n' > <outfile>
2009-07-07 01:17:47
User: qubyte
Functions: tr
Tags: shell tr

Puts words on new lines, removing additional newlines.

for x in *.ogg; do ffmpeg -i "$x" "`basename "$x" .ogg`.mp3"; done
2009-09-04 20:23:09
User: Superhuman
Tags: ffmpeg ogg mp3 for

Converts all ogg files to mp3 files in the current directory.

rm -R `ls | egrep -v 'dir1|dir2|file1'`
netstat -an | grep --color -i -E 'listen|listening'
cat /etc/psa/.psa.shadow
2009-04-30 18:08:12
User: jigglebilly
Functions: cat

I'm sure almost everybody knows this by now. This command will pull the password for the admin login of any plesk machine.

mencoder mf://image1.jpg,image2.jpg,image3.jpg -mf w=800:h=600:fps=25:type=jpeg -ovc copy -oac copy -o output.avi
2009-10-21 09:17:22
User: eastwind

syntax :

mencoder mf://filemask -mf

option availble for mf :

* w=value : the width of the output, by d?fault : autodetected

* h=value : height of the output, by default : autodetected

* fps=value : framerate of the output, by default : 25

* type=value : file format type input , avaible: jpeg, png, tga, sgi

lynx -dump -head http://www.example.com/
2009-03-31 18:41:36
User: penpen

Without the -dump option the header is displayed in lynx. You can also use w3m, the command then is

w3m -dump_head http://www.example.com/
file /usr/bin/* | grep ELF | cut -d":" -f1
2010-02-17 14:01:52
Functions: cut file grep

This is a dirty raw way to simply list ELF objects in a folder.

The output is ready to be parsed i.e to the stripper or what else needs a path to an ELF object.

gmetric -n $METRIC_NAME -v foo -t string -d 10
2009-05-29 14:21:24
User: root
Tags: ganglia

The -d flag sets the lifetime of a metric and defaults to 0 hence why old metrics continue to be graphed in the dashboard. Submitting a dummy value and short lifetime ensures that the metric is removed from the dashboard.

echo capitalize | { dd bs=1 count=1 conv=ucase 2> /dev/null; cat ;}
lsusb -v | grep -o "[0-9A-Z]{16}"
2009-11-22 00:58:00
User: matthewbauer
Functions: grep lsusb
Tags: ipod

This is a bit of a hack, but it will get your fwguid which is needed sometimes when using your iPod.

cat video.ogg | nc -l -p 4232 & wget http://users.bshellz.net/~bazza/?nombre=name -O - & sleep 10; mplayer http://users.bshellz.net/~bazza/datos/name.ogg
members () { dscl . -list /Users | while read user; do printf "$user "; dsmemberutil checkmembership -U "$user" -G "$*"; done | grep "is a member" | cut -d " " -f 1; };
2012-05-20 11:34:33
User: eduo
Functions: cut grep printf read

Group membership in OS X is a mish-mash of standards that end up meaning there's almost a half-dozen of ways to belong to a group, what with group inheritance and automatic assignment. This means there's no easy command to find out all groups a user belongs to. The only sensible way then is to list all users and then query each user for membership.

NOTE: This is a function. Once input you can execute it by calling with a groupname.

tree -ah --du . | ack '\[(\d{3,}M|\d+.*G)\]'