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
tw translate.google.com.de-en `xsel`
2010-06-11 22:28:28
User: dbbolton

Translate the X selection from German to English. The tw program is available from Savannah: http://mirror.its.uidaho.edu/pub/savannah/twandgtw/

I'm posting this because the base Debian system also does not include curl.

/usr/local/bin/OFPW -mode 1
perl -wlne 'print $1 if /(([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5]))/' iplist
2009-09-17 16:14:52
User: salparadise
Functions: perl

if you want to only print the IP address from a file.

In this case the file will be called "iplist" with a line like "ip address"

it will only print the "" portion

2011-05-02 14:44:41
User: Nbeker

Learning cardinal and ordinal numbers in Spanish, with the best sounds files, try to get the best way to improve youLearning cardinal and ordinal numbers in Spanish, with the best sounds files, try to get the best way to improve your vocabulary.

xpath () { xmllint --format --shell "$2" <<< "cat $1" | sed '/^\/ >/d' }
2011-12-20 08:34:11
User: sharfah
Functions: sed
Tags: xml xmllint xpath

This function uses xmllint to evaluate xpaths.

Usage: xpath /path/to/element XMLfile

copy /b part.1 + part.2 + part.n file.extension
echo | egrep -e '^(([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-4])\.){3}([01]?[0-9]{1,2}|2[0-4][0-9]|25[0-4])$'
2009-09-17 17:40:48
User: arcege
Functions: echo egrep

Handles everything except octets with 255. Ran through ip generator with variable octet lengths.

sudo usermod -p $(mkpasswd '') user_id
2010-05-06 20:39:58
User: ckclark
Functions: sudo usermod

It is safe when there is

"PermitEmptyPasswords no"

in /etc/ssh/sshd_config.

This command is useful when there is no need to have a password.

awk '{print $0/60;}' /proc/uptime
2011-08-31 10:41:21
User: ioggstream
Functions: awk

Get info directly from /proc/uptime

ssh -XfC -c blowfish user@host Xephyr dpms -fullscreen -query localhost :5
2012-11-01 18:59:57
User: hute37
Functions: ssh
Tags: ssh X Xephyr xdmcp

ssh compresion -C option ...

on slow connection VNC performs better but in local LAN native secure X protocol is an option

curl curlmyip.com
%s/?/\&iuml;/ge | %s/?/\&#0233;/ge | %s/?/"/ge | %s/?/"/ge | %s/?/'/ge | %s/?/'/ge | %s/?/\&ecirc;/ge | %s/?/\&#0133;/ge | %s/?/\&#232;/ge | %s/?/\&#243;/ge | %s/?/\&ouml;/ge | %s/?/\&#0233;/ge | %s/?/\&ndash;/ge | %s/?/\&mdash;/ge
2010-07-15 07:40:45
User: miccaman
Tags: vim

a brief list of very common special characters in Dutch. Usefull for formatting Word source to html.

find ./ -iname "*.mp3" -type f -printf "mv '%p' '%p'\n" | sed -e "s/mp3'$/mp3'/I" | sh
2009-03-27 13:42:40
User: jnash
Functions: find sed

Extensible to other ugly extensions like *.JPG, *.Jpg etc..

Leave out the last pipe to sh to perform a dry run.

for i in {0..1}{0..9}; do echo $i; done
2009-09-18 02:51:12
User: dennisw
Functions: echo
Tags: bash strings

Bash 4 will let you do {00..19} to get leading zeros, but Bash 3 doesn't have that feature. This technique gets you partway there (the sequences need be such that the last digit ranges from zero to nine - you can't use this for something like Bash 4's {03..27}, for example). When this limitation is not a problem, you can avoid some complicated string manipulation for concatenating leading zeros.

You can add more digits like this: {0..1}{0..9}{0..9} (ranges from 0 to 99 with up to two leading zeros). To pad with additional zeros:

for i in 000{0..1}{0..9}; do echo $i; done


for i in {0..1}{0..9}; do echo "000$i"; done

This is useful for creating values to sort or for creating filenames with a fixed format. Note that this will also work:

touch {0..1}{0..9}
gst-launch avimux name=mux ! filesink location=out.avi \ alsasrc ! audioconvert ! queue ! mux. istximagesrc name=videosource use-damage=false ! video/x-raw-rgb,framerate=10/1 ! videorate ! ffmpegcolorspace ! video/x-raw-yuv,framerate=10/1 ! mux.
2010-07-15 09:39:51
User: Nicolargo

The command generate an huge output file (depending on screen resolution and time).

pbzip2 -dck <bz2file> | tar xvf -
jda() { cd $(pwd | sed "s/\(\/$@\/\).*/\1/g"); }
find . -type f \( -name "*.js" -o -name "*.php" -o -name "*.inc" -o -name "*.html" -o -name "*.htm" -o -name "*.css" \) -exec grep -il 'searchString' {} \;
2010-02-07 15:28:20
User: niels_bom
Functions: find grep
Tags: find grep search

Use find to recursively make a list of all files from the current directory and downwards. The files have to have an extension of the ones listed. Then for every file found, grep it for 'searchString', returns the filename if searchString is found.

alias dush="du -xsm * | sort -n | awk '{ printf(\"%4s MB ./\",\$1) ; for (i=1;i<=NF;i++) { if (i>1) printf(\"%s \",\$i) } ; printf(\"\n\") }' | tail"
2010-07-15 10:38:27
User: dopeman
Functions: alias

Essentially the same as funky's alias, but will not traverse filesystems and has nicer formatting.

sed -e "s,/\+$,," -e "s,^/\+,," file.txt
2012-11-02 21:08:30
User: bugmenot
Functions: sed

There can be more than one trailing slash, all of them will be removed.

@echo off && sc create CmdAsSystem type= own type= interact binPath= "cmd /c start cmd /k (cd c:\ ^& color ec ^& title ***** SYSTEM *****)" && net start CmdAsSystem && sc delete CmdAsSystem
2010-02-07 15:28:28
User: willemijns

In 2014, ask a kind of specific UAC authorization to run due to his dangerousity.

ifconfig eth0|awk '/HWaddr/{gsub(/:/,"",$5);print $5}'
DD=`cat /etc/my.cnf | sed "s/#.*//g;" | grep datadir | tr '=' ' ' | gawk '{print $2;}'` && ( cd $DD ; find . -mindepth 2 | grep -v db\.opt | sed 's/\.\///g; s/\....$//g; s/\//./;' | sort | uniq | tr '/' '.' | gawk '{print "CHECK TABLE","`"$1"`",";";}' )
2009-07-25 03:42:31
User: atcroft
Functions: cd find gawk grep sed sort tr uniq

This command will generate "CHECK TABLE `db_name.table_name` ;" statements for all tables present in databases on a MySQL server, which can be piped into the mysql command. (Can also be altered to perform OPTIMIZE and REPAIR functions.)

Tested on MySQL 4.x and 5.x systems in a Linux environment under bash.

/usr/bin/Xephyr :5 -query localhost -once -fullscreen -ac -keybd "ephyr,,,xkbmodel=pc105,xkblayout=it,xkbrules=evdev,xkboption="
2012-11-03 01:21:36
User: hute37
Tags: Xephyr xdmcp

XDMCP ust be enabled (gdm,lightdm,xdm etc )