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,586 results
pwd
2013-09-17 20:14:15
User: fhh
Functions: pwd
Tags: xdg-open
-10

exactly same effect as echo "$PWD" ...

wget -q -nd http://www.biranchi.com/ip.php; echo "Your external ip is : `cat ip.php`"
2010-12-20 09:53:59
User: pebkac
Functions: echo wget
-10

This is a convinient way to do it in scripts. You also want to rm the ip.php file afterwards

scp -P 1837 <path_to_loca_file> <remote_user>@<remote_ip>:<remote_ip>
2011-08-31 13:08:16
User: tkembo
Functions: scp
-10

when ssh is running on a different port

grep -r <searchterm> *
init 6
2009-05-29 07:44:05
User: miccaman
Functions: init
Tags: solaris Reboot
-11

init states on solaris are numbered

init 0 boot with prompt

init 5 shutdown

init 6 reboot

yum -y install bind bind-chroot caching-nameserver
ls -R | grep -v skipme | xargs rm -Rf
2013-10-18 08:11:39
Functions: grep ls rm xargs
Tags: delete rm
-11

This command will delete all files and folders except 'skipme'. it could be a file or a folder.

find | xargs chmod 777
firefox http://emacs.vote-system.com/
wget -U Mozilla http://example.com/foo.tar.gz
man bash | col -b
2009-09-10 00:45:27
User: suxer
Functions: bash col man
-11

Display man page in plain text

python -c "import socket; s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM); s.connect(('google.com', 80)); print s.getsockname()[0]"
2009-12-29 19:17:03
User: whiteinge
Functions: python
-11

Requires Python; doesn't require a specific server to return your IP.

dd if=/dev/zero of=junk bs=1M count=1K
2009-11-01 23:45:51
User: guedesav
Functions: dd
Tags: dd ram rm
-11

This is an useful command for when your OS is reporting less free RAM than it actually has. In case terminated processes did not free their variables correctly, the previously allocated RAM might make a bit sluggis over time.

This command then creates a huge file made out of zeroes and then removes it, thus freeing the amount of memory occupied by the file in the RAM.

In this example, the sequence will free up to 1GB(1M * 1K) of unused RAM. This will not free memory which is genuinely being used by active processes.

(cd /source/dir ; tar cv .)|(cd /dest/dir ; tar xv)
2009-07-19 10:31:13
User: marssi
Functions: cd tar
-11

the f is for file and - stdout, This way little shorter.

I Like copy-directory function It does the job but looks like SH**, and this doesn't understand folders with whitespaces and can only handle full path, but otherwise fine,

function copy-directory () { ; FrDir="$(echo $1 | sed 's:/: :g' | awk '/ / {print $NF}')" ; SiZe="$(du -sb $1 | awk '{print $1}')" ; (cd $1 ; cd .. ; tar c $FrDir/ )|pv -s $SiZe|(cd $2 ; tar x ) ; }

echo "your text" > filename
sudo apt-get install msttcorefonts
mkgo newdir
kill -9 `pgrep firefox`
2010-05-02 23:05:25
User: dustindorroh
Functions: kill
-11
pgrep firefox

- this returns the Process ID for the signal firefox

kill -9 pid

- this kills the signal that had the given pid

cmd1 `cmd1` or cmd1 $(cmd1)

- here is the syntax for cmd2 to be executed first. Then the call to cmd2 is substituted with the output of cmd2, and cmd1 is executed.

sleep 10; poweroff
2013-04-13 22:07:15
User: xmuda
Functions: sleep
-11

If you are on your bed, waching a movie or if you are downloading something, but you whant to sleep. You can use these easy command to power off after X time. The time is in sec. if you whant to wait 1 H, use:

sleep 3600; poweroff

sudo cat /dev/mem > /dev/dsp
/usr/bin/lynx -dump http://www.netins.net/dialup/tools/my_ip.shtml | grep -A2 "Your current IP Address is:" | tail -n1 | tr -d ' '|sed '/^$/d'| sed 's/^ *//g'
ls -al
2009-11-12 12:27:32
User: eastwind
Functions: ls
-11

it does provide much more information , the owner , group , the size in byte , and the last modified time a file or directory was

ls -al : list all in long format

mplayer -vo caca foo.avi
2009-05-25 09:29:24
User: farwarx
-11

Permet de lire une video dans une console, meme sans interface graphique.

Interet limite, mais a connaitre au cas ou.

whois cmd.fu;whois cmdfu.com|grep -i cmdfu
2009-02-19 08:57:50
User: axelabs
Functions: whois
-11

It would be nice if commandlinefu.com had a better domain name. Will they pick one of the above; We'll see.