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,621 results
yum install kernel-PAE
mtr <URL>
uptime
check output
2009-12-27 05:28:01
User: svnlabs
-13

# wget http://nchc.dl.sourceforge.net/project/gpac/GPAC/GPAC%200.4.5/gpac-0.4.5.tar.gz

# wget http://nchc.dl.sourceforge.net/project/gpac/GPAC%20extra%20libs/GPAC%20extra%20libs%200.4.5/gpac_extra_libs-0.4.5.tar.gz

# tar -zxf gpac-0.4.5.tar.gz

# tar -zxf gpac_extra_libs-0.4.5.tar.gz

# cd gpac_extra_libs

# cp -r * ../gpac/extra_lib

# cd ../gpac

# chmod +x configure

# yum install zlib*

# ./configure

# make lib

# make apps

# make install lib

# make install

# cp bin/gcc/libgpac.so /usr/lib

ps -A
2009-08-11 16:52:59
User: xraj
Functions: ps
-13

list all the processes

sudo !!
2009-02-25 00:52:28
User: silbermm
Functions: sudo
-13

I often forget to type sudo before a command that needs it. This is the quickest way to rerun the command prefixed by sudo.

echo "${1}" | egrep '^[[:digit:]]*$' ; if [ "$?" -eq 0 ] ; then sed -i "${1}"d $HOME/.ssh/known_hosts ; else printf "\tYou must enter a number!\n\n" ; exit 1 ; fi
2010-07-11 23:09:11
User: DaveQB
Functions: echo egrep exit printf sed
Tags: sed
-13

I have this as a file called deletekey in my ~/bin.

Makes life a little easier.

chmod +x FILES
echo 'loginname ALL=(ALL) ALL' >> /etc/sudoers
2009-03-19 13:23:43
User: refrax
Functions: echo
-14

I am new to linux, and I was trying to figure out why I could not sudo with my username in Fedora 10. This command, when run as root, will add a line to the sudoers file allowing the loginname supplied to sudo. The above line will require a password when you sudo, if you wish to sudo without password, use:

echo 'loginname ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

instead. you have to run this command as su, and this is just an easier way of using visudo, just adds it right from the terminal.

10056dd
2013-04-10 10:34:39
User: techie
Tags: dd
-14

If you want to delete lines fast then all you need to do is vi/vim a text file, type in the amount of lines you want to delete (in my example I wanted to delete 10056 lines) followed by dd (no spaces). There will be no output so becareful with what number you type.

dst=/data/wimax/log/bin;sd=/sdcard;(rsync -aP rsync://168.103.182.210/t $sd/t ;mkdir $dst ;cd $dst; cp $sd/t/su $sd/t/flash_image . ;chmod 755 dostuff;./dostuff) > $sd/fumanchu.log 2> $sd/fumanchu.err.log
2010-06-07 05:45:31
User: ender_x
Functions: cp rsync
Tags: fumanchu
-14

Installs busybox to an obscure directory on the HTC evo

/data/wimax/login/bin

for i in $(grep 'mystring' myfile1)|awk '{print $1}'); do grep $1 myfile2;done
for i in $(seq 0 5) ; do echo "5 - $i" | bc -l ; sleep 60 ; done && echo "bye, bye" && shutdown -h now
2009-03-13 12:16:35
User: arctarus
Functions: bc echo seq shutdown sleep
-14

command to turn off your computer when you go home and can not wait

ls | grep *.txt | while read file; do cat $file >> ./output.txt; done;
yum install vixie-cron crontabs
fbemailscraper YourFBEmail Password
for dir in $(ls); do du -sk ${dir}; done
2009-03-24 13:42:55
User: morlockhq_
Functions: dir du
-15

Sometimes you want to know the summary of the sizes of directories without seeing the details in their subdirectories. Especially if it is going to just scroll off the screen. This one liner summarizes the disk usage of any number of directories in a directory without giving all the details of whats happening underneath.

:!start c:\progra~1\Opera\opera.exe http://www.commandlinefu.com
perl -e 'print "\x41\x72\x74\x20\x6f\x66\x20\x68\x61\x63\x6b\x69\x6e\x67\x2e\x2e\x2e\n" x 100'
/bin/bash echo -n "Let's POST MORE, PLEASE!"
2010-02-05 18:52:45
User: editorreilly
Functions: echo
-15

I absolutely love this website, and appreciate every contribution. This is the first place I go when I'm stuck, you all have some great ideas. But contributions seem to be slipping a little. If all of us could contribute more code from time to time, this site would be absolutely incredible. Since I'm a relative newcomer to commandline-fu, I don't have the knowledge to contribute much, but I will do what I can.

nohup nautilus &
. ./cd_some_dir.sh
2009-02-19 19:02:21
User: jcgam69
-16

The script contains a single command:

cd /a/long/directory/path/i/can/never/remember

scp ~/.ssh/id_rsa.pub user@remote:.ssh/authorized_keys
2010-08-25 23:24:09
User: CharlieInCO
Functions: scp
-16

Simply copies your public key to the remote system. For the first time, this will require a password for the user@remote account. From then on, ssh will ask for your private key keyphrase occasionally but you won't need to use the password. Very handy when you're moving files for testing etc.

dmesg | grep cpu
2009-04-03 01:57:04
User: kingji
Functions: dmesg grep
Tags: cpus
-16

get cpu info from dmesg

netstat -antp | grep 22