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.


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 - 11,848 results
find /dir/ -name *name*
2009-02-09 20:24:10
User: cinan
Functions: find

"*" is important if you don't know exact name of file. Check it out and you'll see

find . -exec chmod 777 {} \;
pkill $1
2009-07-20 12:47:41
User: svg

There's already a proper command for what the former alternative tried to script

echo alias xkcd="gwenview `w3m -dump http://xkcd.com/|grep png | awk '{print $5}'` 2> /dev/null" >> .bashrc
2010-01-30 20:38:16
User: GinoMan2440
Functions: alias echo

Add an alias to your .bashrc that allows you to issue the command xkcd to view (with gwenview) the newest xkcd comic... I know there are thousands of them out there but this one is at least replete with installer and also uses a more concise syntax... plus, gwenview shows you the downloading progress as it downloads the comic and gives you a more full featured viewing experience.

can(){ shift 2; sudo "$@"; }
lynx --dump http://ip.boa.nu|sed -e 's/^[[:space:]]*//' -e 's/*[[:space:]]$//'|grep -v ^$
2009-11-04 22:23:45
User: xeor
Functions: grep sed

For those of us that still uses lynx :)

print -l $path
2009-08-27 16:33:04
User: Mikachu
Tags: zsh PATH

This doesn't work in bash, but in zsh you can typeset -T to bind a scalar variable to an array. $PATH and $path behave this way by default.

echo *
2009-04-17 21:40:58
User: kFiddle
Functions: echo
Tags: echo ls

Sometimes "ls" is just too slow, especially if you're having problems with terminal scroll speed, or if you're a speed freak. In these situations, do an echo * in the current directory to immediately see the directory listing. Do an echo * | tr ' ' '\n' if you want a column. Do an alias ls='echo *' if you want to achieve higher echelons of speed and wonder. Note that echo * is also useful on systems that are so low in memory that "ls" itself is failing - perhaps due to a memory leak that you're trying to debug.

rm ~/.bash_history && kill -9 $$
2009-10-08 12:25:47
User: Velenux
Functions: kill rm

Best way I know to get rid of .bash_history and don't allow bash to save the current one on exit

Edit: added ~/ before .bash_history, just in case... ;)

while read col1 col23; do echo $col1; done < three-column.txt > first-column.txt
jot -b '' 100
ls -1 | sort -R | sed -n 's/^/Selected /;1p'
tail -n +4 | head -n 1
grep '^[^#]' squid.conf
2013-02-21 18:51:06
User: Flow
Functions: grep
Tags: regex grep,

grep '^[^#]' sample.conf

\__/ |||| \_________/

| |||| |

| |||| \- Filename

| ||||

| |||\- Only character in group is '#'

| |||

| ||\- Negate character group (will match any cahracter *not* in the

| || group)

| ||

| |\- Start new character group (will match any character in the

| | group)

| |

| \- Match beginning of line


\- Run grep

Empty lines will also be not matched, because there has to be at least one non-hash-sign character in the line.

ls -R .
rm ~/.bash_history; ln -s /dev/null ~/.bash_history
2009-10-08 17:40:48
Functions: ln rm

Remove your BASH history and then link it to /dev/null

2009-10-08 23:06:00
User: felix001

Shows the status of SElinux.

-- fir3net.com --

sudo update-grub
2014-02-27 19:50:25
User: Anshik
Functions: sudo

sudo gedit /etc/default/grub

This would open the Grub configuration file. In this file we have to edit the line




tail -n +<N> <file> | head -n 1
2011-09-30 08:30:30
User: qweqq
Functions: head tail

Tail is much faster than sed, awk because it doesn't check for regular expressions.

figlet gunslinger_
ps -ef | grep pmon
find . -type d -exec chmod 0755 {} \;
2009-02-18 14:38:22
User: osantana
Functions: chmod find

WARNING! This command may set an invalid permission under your current directory.

This command will set the 0755 permissions to all directories under your current directory. An alternative version of this command is: find ~/.ssh -type d -exec chmod 0700 {} \;

ls -laR > /path/to/filelist
2009-08-12 17:53:40
User: shaiss
Functions: ls

Ever need to output an entire directory and subdirectory contents to a file? This is a simple one liner but it does the trick every time. Omit -la and use only -R for just the names

while (( 1==1 )); do du -c . >> output.log; sleep 2; done; tail -f output.log
2010-07-12 17:23:45
User: aceiro
Functions: du sleep tail

this command shows the space used in postgres directory.