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
mvn archetype:create -DgroupId=my.work -DartifactId=MyProject
2009-05-20 12:53:23
User: sharfah
Tags: maven

This will create a new directory called MyProject with a pom.xml and the following tree structure:




| |-->main

| | |-->java

| | | |-->my

| | | | |-->work

| | | | | |-->App.java

| |-->test

| | |-->java

| | | |-->my

| | | | |-->work

| | | | | |-->AppTest.java

cd "$(mktemp -d)"
2009-05-20 11:48:12
User: Weboide
Functions: cd
Tags: bash directory

This command create a new temp directory using mktemp (to avoid collisions) and change the current working directory to the created directory.

find /home/fizz -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort
tr "[:upper:]" "[:lower:]" < file
fold -w 78 -s file-to-wrap
2009-05-19 19:33:10
User: GeckoDH
Functions: fold

Per default, linux/unix shells are configured with a width of 80 characters.

If you like to edit a phrase or string on a line with more than 80 characters it might take long to go there (for example a line with 1000 characters and you like to edit the 98th word which is character 598-603).

Maybe you might wish to use 78 characters, because if you forward the text via mail and the text will be quoted (2 extra characters at the beginning to the line "> "), you use 80 characters, otherwise 82, which are lame.

mencoder -aid 2 -oac copy file.avi -o english.mp3
notifyme -C `cat /etc/passwd | cut -d: -f1`
2009-05-19 19:17:05
Functions: cut

Notifyme is a program that listen in background for users login, and report on login and logout. Users can be specified from a list or in a ~/notify.rc file. -C options force to display messages on the center of the screen.See man notifyme for more details. Part of notifyme package, tested on Debian.

screen -x
2009-05-19 19:10:52
User: GeckoDH
Functions: screen

Ater person A starts his screen-session with `screen`, person B can attach to the srceen of person A with `screen -x`. Good to know, if you need or give support from/to others.

2009-05-19 19:07:11

From man tiger : Tiger is a package consisting of Bourne Shell scripts, C code and data files which is used for checking for security problems on a UNIX system. It scans system configuration files, file systems, and user configuration files for possible security problems and reports them.

mytop --prompt
2009-05-19 19:04:57

mytop is a top like monitor for displaying Mysql server statistic and performance. Part of mytop package ,tested on Debian.

sed -i 'your sed stuff here' file
count() { find $@ -type f -exec cat {} + | wc -l; }
who -b
2009-05-19 11:52:54
User: sharfah
Functions: who

Displays time of last system boot

sar -r
2009-05-19 11:47:38
User: sharfah

Report memory and swap space utilization statistics e.g. memory free/used, swap free/used

kill -0 [pid]
2009-05-19 11:37:20
User: sharfah
Functions: kill
Tags: kill

Send signal 0 to the process. The return status ($?) can be used to determine if the process is running. 0 if it is, non-zero otherwise.

tar cvf - foodir | gzip > foo.tar.gz
2009-05-19 11:33:51
User: sharfah
Functions: gzip tar
Tags: tar gzip

Where foodir is the directory you want to zip up.

gunzip < foo.tar.gz | tar xvf -
curl -d 'username=root&password=your-good-password' "http://router/cgi-bin/luci/admin/system/backup?backup=kthxbye" > `date +%Y%d%m`_config_backup.tgz
2009-05-19 11:32:30
User: GeckoDH

You only have to fill in your administrative account and password, and the router FQDN!

I recommand to execute this command not over the internet, because there is no encryption (the username and password will be transmitted in plaintext!)

VARNAMES='ID FORENAME LASTNAME ADDRESS CITY PHONE MOBILE MAIL' ; cat customer.csv | while read LINE ; do COUNT=1 ; for VAR in $VARNAMES ; do eval "${VAR}=`echo $LINE | /usr/bin/awk {'print $'$COUNT''}`" ; let COUNT=COUNT+1 ; done ; done
2009-05-19 11:23:00
User: GeckoDH
Functions: cat eval read


cat customer.csv | while read LINE ; do


for VAR in $VARNAMES ; do

eval "${VAR}=`echo $LINE | /usr/bin/awk {'print $'$COUNT''}`"




Maybe you have a CSV-File with addresses, where you have to process each contact (one per line, write each value to own variable). Of course you can define every variable, but this way is more simple and faster (to write).

VARNAMES includes the variable names. Pay attention: the number of names in VARNAMES have to be the same than in the CSV-file the fields. If the CSV is not seperated with ";", you can set the seperator after the awk-binary with -F"_" for example.

find . -type d -exec rmdir {} \;
2009-05-19 08:59:15
User: sharfah
Functions: find rmdir
Tags: find rm

Deletes empty directories and prints an error if directory is not empty.

TOM=`perl -w -e '@tom=localtime(time+86400);printf "%d%.2d%.2d",$tom[5]+1900,$tom[4]+1,$tom[3];'`
2009-05-19 08:54:27
User: sharfah
Tags: perl

Returns tomorrow's date in the format yyyyMMdd

YEST=`perl -w -e '@yest=localtime(time-86400);printf "%d%.2d%.2d",$yest[5]+1900,$yest[4]+1,$yest[3];'`
2009-05-19 08:54:06
User: sharfah
Tags: perl

Returns yesterday's date in the format yyyyMMdd

INPUT=<input_video> && ffmpeg -i "$INPUT" -vn -f wav - | oggenc -o ${INPUT%%.*}.ogg -
2009-05-19 07:57:43
User: DaveQB

Assumes you have ffmpeg and oggenc.

Similar to other scripts here, but this time outputting to Ogg Vorbis.

I added the variable assignment for a nice output name.

This is part of an interactive bash script I have with a few little multimedia tasks in it.


uuencode archive.tar.gz archive.tar.gz | mail -s "Emailing: archive.tar.gz" user@example.com
2009-05-19 07:17:37
Functions: mail uuencode

The uuencode utility will encode your file so that it can be sent as an attachment to an email. It is part of the sharutils package in RHEL/CentOS/Fedora.

mailx bar@foo.com -s "HTML Hello" -a "Content-Type: text/html" < body.htm
2009-05-19 04:49:26
User: ethanmiller
Functions: mailx
Tags: mail smtp html

Note, this works because smtp is running