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:



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.




All commands from sorted by
Terminal - All commands - 12,034 results
msiexec.exe /i product.msi /l* c:\folder\LogFileName.txt
mysqldump -uUserName -pPassword tudb | ssh [email protected] "mysql -uUserName -pPassword -h mysql.rootsvr.com YourDBName"
2009-02-17 22:36:06
User: elecboy
Functions: ssh

This option makes a copy of your current db and via ssh it transfer to the server you specify and upload the database to the specific User & Password you specify (Note the db User & Pass, can be different from the one you use in the other server)

If you are going to use "localhost" as your main db remove (-h) and youst add "localhost"

svn log -q|grep "|"|awk "{print \$3}"|sort|uniq -c|sort -nr
2009-02-17 21:37:03
User: psytek

Use this command to find out a list of committers sorted by the frequency of commits.

echo "^[]0;My_Title_Goes _Here^G"
2009-02-17 20:46:06
User: TheNomad
Functions: echo

If you are using an xterm emulation capable terminal emulator, such as PuTTY or xterm on Linux desktop, this command will replace the title of that terminal window. I know it is not nice to have seventeen terminals on your desktop with title PuTTY, you can not tell which one is connected to which server and doing what.

Even though the string between the quotes is typed as literals, it needs a little more finesse to make it work. Here is how it is done key-by-key:

echo "( ctrl-v then ctrl-[ )0;Enter_Title_String_Here( ctrl-v then ctrl-g )"( enter )

ctrl-v : means hold down ctrl key and hit v at the same time like you are pasting in windoze ; also please don't type the parentheses, i.e., ( and )

ps -ef | grep $USERNAME | awk {'print $2'} | xargs kill [-9]
2009-02-17 20:35:35
User: TheNomad
Functions: awk grep kill ps xargs

This is a 'killall' command equivalent where it is not available.

Prior to executing it, set the environment variable USERNAME to the username, whose processes you want to kill or replace the username with the $USERNAME on the command above.

Side effect: If any processes from other users, are running with a parameter of $USERNAME, they will be killed as well (assuming you are running this as root user)

[-9] in square brackets at the end of the command is optional and strongly suggested to be your last resort. I do not like to use it as the killed process leaves a lot of mess behind.

ls -lrt
2009-02-17 19:51:08
User: guidouil
Functions: ls

Show you the list of files of current directory sorted by date youngest to oldest, remove the 'r' if you want it in the otherway.

find /home -uid 1056 -exec chown 2056 {} \;
2009-02-17 19:42:50
Functions: chown find

Finds all files in /home owned by UID 1056 and changes to 2056.

find . -size +10240k -exec ls -l {} \; | awk '{ print $5,"",$9 }'|sort -rn > message.out
2009-02-17 19:39:56
User: rommelsharma
Functions: awk find ls

This command specifies the size in Kilobytes using 'k' in the -size +(N)k option. The plus sign says greater than. -exec [cmd] {} \; invokes ls -l command on each file and awk strips off the values of the 5th (size) and the 9th (filename) column from the ls -l output to display. Sort is done in reversed order (descending) numerically using sort -rn options.

A cron job could be run to execute a script like this and alert the users if a dir has files exceeding certain size, and provide file details as well.

watch ifconfig eth0
sudo find / -user root -perm -4000 -print
2009-02-17 18:10:31
User: tlknv

Use ^D instead of exit.

Also ^D ends input stream when you use terminal for typing into standard input.

mysqldump --add-drop-table --extended-insert --force --log-error=error.log -uUSER -pPASS OLD_DB_NAME | ssh -C user@newhost "mysql -uUSER -pPASS NEW_DB_NAME"
2009-02-17 17:57:53
User: Tscherno
Functions: ssh

Dumps a MySQL database over a compressed SSH tunnel and uses it as input to mysql - i think that is the fastest and best way to migrate a DB to a new server!

vncserver -nohttpd -name hidef-server -depth 24 -geometry 1440x900
2009-02-17 17:50:33
User: starchox
Tags: Network , net

-nohttpd don't run mini-httpd if VNC java applet is found

-name change the name of the desktop, it's passed to xstartup script via $VNCDESKTOP, run different set of apps acording the name.

-depth pixel depth in bits of the desktop, default is 16

-geometry size of the desktop, default is 1024x768

cd `pwd -P`
2009-02-17 17:21:24
User: Davvolun
Functions: cd

If you use symlinks a lot, especially nested symlinks, this puts you back on the absolute path to command-line-fu-nirvana. (Note the backticks around pwd).

history -w <switch to another terminal> history -r
2009-02-17 17:11:31
User: tlknv

Or just do history -w before opening another terminal.

ls -1 . dir2 dir3|sort|uniq -d
2009-02-17 16:29:03
User: tlknv
Functions: ls

cat file1 file2 file3|sort|uniq -d

finds the same lines in several files, especially in files with lists of files.

ssh -CNL 3306:localhost:3306 [email protected]
ssh -D 8888 [email protected]
2009-02-17 15:34:27
User: wesrog
Functions: ssh

Simply change your web browser's proxy settings to point to a SOCKS proxy at port 8888 and you're good to go.

kill -9 $$
2009-02-17 15:10:29
User: chanux
Functions: kill

Kill -9 immediately kills the given process number. $$ is the process ID of the process you are in.

find apps/ -name "*.svn-base" -prune -o -print -name "*.php" | xargs grep -E 'new .+Form\('
2009-02-17 14:56:01
User: ubermuda
Functions: find grep xargs

finds all forms instanciated into a symfony project, pruning svn files.

mkdir -p work/{d1,d2}/{src,bin,bak}
perl -pe 's/\d+/++$n/e' file.txt
cat /proc/cpuinfo
2009-02-17 14:50:29
User: stinger
Functions: cat

how to get full cpu info of your (linux) box

ls -1 /bin | xargs -l1 whatis 2>/dev/null | grep -v "nothing appropriate"
2009-02-17 14:46:01
User: stinger
Functions: grep ls whatis xargs

Get simple description on each file from /bin dir, in list form, usefull for newbies.