Hide

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.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

All commands from sorted by
Terminal - All commands - 11,860 results
export PSOA='user,pid,time,state,command' ; function _ps { /bin/ps $@ ; } ; alias psa='_ps ax -o $PSOA'
2010-05-27 02:07:56
User: mattmartini
Functions: alias export
-1

#ps aliases

PSO='user,pid,ppid,%cpu,%mem,time,start,state,command'

PSOA='user,pid,time,state,command'

PSOL='user,pid,ppid,%cpu,%mem,nice,pri,etime,time,tt,state,ucomm'

export PSO PSOA PSOL

function _ps { /bin/ps $@ ; }

alias ps='_ps ax -o $PSO'

alias psa='_ps ax -o $PSOA'

alias psl='_ps ax -o $PSOL'

alias psm='_ps -U $USER -o $PSOA'

svn log . --stop-on-copy
2010-02-24 12:37:18
User: reaper
-1

The command show the log of a branch, stopping the output at the time of branch creation.

xterm +u8 -fn mtx -maximized -T "There is no spoon!" -e cmatrix -bxa -u 3 & sleep .1s && wmctrl -r :ACTIVE: -b add,fullscreen && transset-df -a &
2012-09-28 04:46:28
User: bugmenot
Functions: sleep
-1
apt-get install cmatrix cmatrix-xfont wmctrl transset-df

Need to restart computer for mtx font to work

Commands while cmatrix is running:

1 - 9 = Change speed

SHIFT + 1 - 7 = change colors

Q = Quit

Tested in Ubuntu 10.04

twistd -no web
2014-02-01 22:35:50
User: nkorth
-1

Install twistd first with

sudo apt-get install python-twistd-web
cd /usr/ports; grep -F "`for o in \`pkg_info -qao\` ; \ do echo "|/usr/ports/${o}|" ; done`" `make -V INDEXFILE` | \ grep -i \|ports@freebsd.org\| | cut -f 2 -d \|
2009-02-16 21:07:35
User: grep
Functions: cd cut grep
-1

only works for freeBSD where ports are installed in /usr/ports

credit to http://wiki.freebsd.org/PortsTasks

CTRL + a
export PS1='\D{%a %D %T}> '
cd -
2011-07-05 05:28:32
Functions: cd
-1

Add dirs to list:

pushd /tmp

/tmp ~

then

cd -

/home/user

cd -

/tmp

RANGE=`wc -l /usr/share/dict/words | sed 's/^\([0-9]*\) .*$/\1/'`; for i in {1..4}; do let "N = $RANDOM % $RANGE"; sed -n -e "${N}p" /usr/share/dict/words | tr -d '\n'; done; RANGE=100; let "N = $RANDOM % $RANGE"; echo $N
while :; do cat file.txt | nc -l 80; done
vim -c'highlight Comment ctermfg=white' my.conf
2011-10-21 00:53:03
User: kev
Functions: vim
Tags: vim
-1

you should choose proper color to make comments invisible.

Boot up destination machine with Knoppix live CD and run nc -l -p 9000 | dd of=/dev/sda Then on the master dd if=/dev/sda | nc <dest-ip> 9000 You can monitor bandwidth usage to see progress: nload eth0 -u M
2009-05-07 05:26:58
User: lv4tech
Functions: dd
-1

This is a bit to bit copy so if you have a 500GB hard disk it will take a long time even if have Gigabit Ethernet

printf "%s\n" !(pattern) ## ksh, or bash with shopt -s extglob
2009-11-26 14:09:56
User: cfajohnson
Functions: bash printf
Tags: ls grep
-1

There's no need for ls or grep; printf is builtin to most modern shells

echo "Terrorist threat level: `sed $(perl -e "print int rand(99999)")"q;d" /usr/share/dict/words`"
2011-01-28 09:49:37
User: houghi
Functions: echo
-1

Numbers are less understandable then words. Also this may put out a different result.

sort -R /usr/share/dict/british | grep -v -m4 ^\{1,10\}$ | tr [:upper:] [:lower:] | tr "\n" " " | tr -d "'s" | xargs -0 echo
2011-08-16 10:11:21
User: takac
Functions: grep sort tr xargs
Tags: tr xkcd
-1

Doesn't use shuf, its much faster with "shuf -n4" instead of sort -R

pcregrep --color -M -N CRLF -e "SQLEngine\.\w+\W*\([^\)]*\)" -r --include='\.java$'
tcpdump -s 1024 -l -A -n host 192.168.9.56
2013-02-02 22:29:52
User: wejn
Functions: host tcpdump
Tags: http tcpdump
-1

This is a better way to do the "src X or dst X" filter; plus you might not want to bother with DNS lookups (-n).

aspell -d en dump master | aspell -l en expand > words
xdg-open .
2010-10-05 04:20:31
User: schlaegel
-1

Opens the current working directory in the user's preferred application using freedesktop.org's xdg-open.

echo `cat /dev/urandom | base64 | tr -dc "[:alnum:]" | head -c64`
2010-12-06 21:04:57
User: Dereckson
Functions: echo head tr
-1

The same command, but with a base64 filter, more forgiving for special characters than tr.

sed 's/.$//' Win-file.txt
VBoxManage list systemproperties
2010-04-23 06:43:49
User: 0disse0
Tags: virtualbox
-1

How to show the system properties of a Sun VirtualBox server

wget --quiet -O - checkip.dyndns.org | sed -e 's/[^:]*: //' -e 's/<.*$//'
2010-08-01 13:36:08
User: berkes
Functions: sed wget
Tags: ip address
-1

Wgets "whatismyip" from checkip.dyndns.org and filters out the actual IP-adress. Usefull when you quickly need to find the outward facting IP-address of your current location.

exiv2 *JPG | grep Focal | awk '{print $5}' | sort -n | uniq -c
2011-07-05 11:25:29
User: ivanatora
Functions: awk grep sort uniq
-1

First column is number of photos, second column is the focal length.

pdfcrack <FILE>