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,488 results
(($RANDOM%6)) || echo 'hello world!'
2009-05-27 08:11:08
User: luishka
Functions: echo
-8

ramdomize the execution of the command echo 'hello world!'

rm -rf ~/.local/share/Trash/files/*
cd -
vim -R /etc/passwd
cd /etc/init.d && sudo ./apache2 start
2010-04-17 16:01:18
User: nco
Functions: cd sudo
-9

This command is designed in order to avoid this error :

/etc/init.d/apache2 force-reload

* Reloading web server config apache2 httpd not running, trying to start

(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80

no listening sockets available, shutting down

Unable to open logs

[fail]

scp -P 22 /home/svnlabs.txt root@92.178.0.56:/home/svnlabs.txt
2010-01-22 17:21:07
User: lalit241
Functions: scp
Tags: a2zfa file cop
-9

Upload file to remote server using SCP

cd -
apt-cache search php5
2012-09-20 21:14:50
User: sudopeople
Functions: apt
-9

Can't remember what that one package was called? Search for it!

It's also a good idea to run

apt-get update

first.

alias b='cd -'
lynx http://shell-fu.org/
2009-08-20 11:47:35
User: penpen
-9

Today I learned that commandlinefu.com is not a alone in its conquest for further the knowledge about the command line. Allow me to introduce you to http://shell-fu.org/

for i in `seq 100`;do mkdir f{1..100} touch myfile$i mv myfile$i f$i;done
history | grep ssh
2009-04-03 01:35:52
User: haivu
Functions: grep
Tags: bash csh
-9

After seeing the command you wish to repeat, just invoke it using the ! syntax.

nautilus `pwd`
find . -type l | xargs file | grep broken
for host in host1 host2 host3; do echo -n $host:; ssh $host uptime; done;
strings /boot/kernel-file | grep 2.6
2009-09-30 06:21:40
Functions: grep strings
-9

recently some in the #linux shared this. to find out the kernel version name from the binary without using uname

dd if=file1 of=file2 seek=1 bs=$(stat -c%s file2)
~<press tab twice>
find -depth . | (while read FULLPATH; do BASENAME=`basename "${FULLPATH}"`; DIRNAME=`dirname "${FULLPATH}"`; mv "${DIRNAME}/${BASENAME}" "${DIRNAME}/${BASENAME// /_}"; done)
2009-03-24 21:04:32
User: mohan43u
Functions: find mv read
-9

Takes filenames and directory names and replace space to '_'.

cat .bash_history | tail -100 | grep {command}
2013-04-10 10:40:52
User: techie
Functions: cat grep tail
-9

I know how hard it is to find an old command running through all the files because you couldn't remember for your life what it was. Heres the solution!! Grep the history for it. depending on how old the command you can head or tail or if you wanted to search all because you cannot think how long ago it was then miss out the middle part of the command. This is a very easy and effective way to find that command you are looking for.

killall -9 <processname>
pwd
2009-02-13 00:31:49
User: rothgar
Functions: pwd
-9

Simply displays your current working directory. Helps when you are buried deep in /etc or some other obscure place.

rush> processes.filter(:cmdline => /mc/).kill
2010-05-01 20:51:18
User: chenge
-9

It's easy to understand and remember. Need ruby and rush to do this.

dd if=yourimage.img of=/dev/sdb1
2009-04-17 23:55:13
User: rissajeanne
Functions: dd
-9

where /dev/sdb1 is the name of your usb device

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

Where foodir is the directory you want to zip up.