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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





All commands from sorted by
Terminal - All commands - 12,273 results
ps auxwww | grep outofcontrolprocess | awk '{print $2}' | xargs kill -9
kill -9 $(pidof process)
ls -rl --time-style=+%s * | sed '/^$/,/^total [0-9]*$/d' | sort -nk6
sudo sh -c 'printf "[SeatDefaults]\nallow-guest=false\n" >/usr/share/lightdm/lightdm.conf.d/50-no-guest.conf'; sudo sh -c 'printf "[SeatDefaults]\nallow-guest=false\n" >/usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf'
2015-08-31 18:12:21
User: andregyn62
Functions: sh sudo

This command will disable a guest user logon, this user don't have password to login in the system.

echo src::${PATH} | awk 'BEGIN{pwd=ENVIRON["PWD"];RS=":";FS="\n"}!$1{$1=pwd}$1!~/^\//{$1=pwd"/"$1}{print $1}'
2009-09-09 04:03:46
User: arcege
Functions: awk echo
Tags: awk echo PATH

Removes trailing newline; colon becomes record separator and newline becomes field separator, only the first field is ever printed. Replaces empty entries with $PWD. Also prepend relative directories (like ".") with the current directory ($PWD). Can change PWD with env(1) to get tricky in (non-Bourne) scripts.

for FILE in `ls -1`; do if [ -L "$FILE" ]; then cp $(readlink "$FILE") ${FILE}_rf; rm -f $FILE; mv ${FILE}_rf "$FILE"; fi; done
echo "Xc" | tr "Xo" "\033\017
kquitapp plasma
2009-02-16 21:27:16
User: raphink
Tags: KDE

KDE4 is great, but still a bit buggy, and sometimes plasma requires to be restarted. Instead of quitting it with "killall plasma", which might loose your preferences (widgets, etc.), kquitapp will cleanly quit it. Tip: you can type this in the "Alt+F2" window, and then type "plasma" in Alt+F2 again to restart plasma (be patient though...).

find $DIR -name *.php -exec vim -u NONE -c 'set ft=php' -c 'set shiftwidth=4' -c 'set tabstop=4' -c 'set noexpandtab!' -c 'set noet' -c 'retab!' -c 'bufdo! "execute normal gg=G"' -c wq {} \;
2011-04-08 11:42:45
User: ruslan
Functions: find vim

The sample command searches for PHP files replacing tabs with spaces.

-u NONE # don't use vimrc

Instead of


one may pass

retab! 4

for instance.

Look at this http://susepaste.org/69028693 also

2013-08-16 20:37:44
User: evilsoup
Tags: vim

Here's the other way of doing it in vim: setting a recursive macro. 'gg' brings you to the top of the buffer, 'qqq' clears the 'q' macro, 'qq' starts recording a macro called 'q', '/^$' moves the cursor to the next empty line, 'dd' deletes the line that the cursor is on, '@q' calls the 'q' macro (currently empty because of 'qqq'), and 'q' stops recording the macro. '@q' calls the macro.

It will run until it cannot find another blank line, at which point it will throw up an error and cease.

While this is longer than the regex, you can use it without having to move your thoughts from 'vim-mode' to 'regex-mode'.

setenv GREP_COLOR '1;37;41'
find . -type d -name DIR -print0 | xargs -r0 rm -r
2009-03-04 14:49:21
User: miguelbaldi
Functions: find rm xargs
Tags: svn cvs

You can use this command to delete CVS/svn folders on given project.

$class=ExampleClass; $path=src; for constant in `grep ' const ' $class.php | awk '{print $2;}'`; do grep -r "$class::$constant" $path; done
curl -s http://whatthecommit.com/ | tr -s '\n' ' ' | grep -so 'p>\(.*\)</p' | sed -n 's/..\(.*\)..../\1/p'
2010-08-02 03:20:32
User: sragu
Functions: grep sed tr

#Sample Usage:

# git commit -m"Jira #404 - `whatthecommit`"


for d in $(find . -maxdepth 1 -type d -name '[^.]*'); do cd "$d"; svn up; cd ..; done
2010-05-28 10:09:19
User: udog
Functions: cd find

If you have a directory with many working copies of various subversion projects and you want to update them all at once, this one may be for you.

ls -i1 filename
awk '/^--- Day changed (.*)/ {st=""; for (i=0;i<ar[date];i++) {st=st"*"} print date" "st; date=$7"-"$5"-"$6} /> emergency/ {ar[date]++} END {st=""; for (i=0;i<ar[date];i++) {st=st"*"}; print date" "st}' #engineyard.log
2010-02-24 23:10:03
User: MarcoN
Functions: awk

This awk command prints a histogram of the number of times 'emergency' is the first word in a line, per day, in an irssi (IRC client) log file.

passpdf(){ for i; do qpdf --password=<YOUR PASSWD> --decrypt "$i" "new$i"; done; }
2010-02-25 01:21:00
User: sputnick
Tags: pdf qpdf

You should install qpdf.

That way, you can have a copy without any password required.

find -D rates . -name "*.mp3" -type f
alias cn='cat > /dev/null'
2011-09-16 00:00:28
Functions: alias

cn stands for "Cat Null"


The idea is that sometimes you run across something on maybe a webpage - like commandlinefu - that you want to try out on your terminal. You could put a '#' in and then paste it, but what if it is several lines?


This command will echo the pasted characters to the screen and divert them to the bit bucket.


Put this simple alias in your .bashrc, hit cn, paste away, and hit a ctrl+c or a ctrl+d when you are done to get your prompt back.

for i in `grep -n "SomeRegEx" foo.txt | sed 's/:/ /' | awk '{print $1}'`; do echo "head -n `echo "$i+4" | bc` foo.txt | tail -n 5"; done > headsandtails.sh
2010-07-01 05:48:02
User: reklis
Functions: awk echo sed

Finds the line number matching the regex, then passes that to BC for some math, passes that to head, and uses tail to trim off the unwanted section at the top. The whole thing is spit out to a script that can then be shared or run. Comes in handy for reading select sections from error logs.

cgrep() { GREP_COLOR="1;3$((RANDOM%6+1))" grep --color=always "$@" }
2011-03-04 18:45:58
User: derekschrock
Functions: grep
Tags: grep

Randomize GNU grep's colors 31-36 excluding black and white.

perl -ne '@a=split(/,/); $b=0; foreach $r (1..$#a){ $b+=$a[$r] } print "$a[0],$b\n"' -f file.csv
2015-09-04 21:05:56
User: miniker84
Functions: perl

For all lines, sum the columns following the first one, and then print the first column plus the sum of all the other columns.

example input:






alias acs='apt-cache search'
wget -H -r ?level=1 -k -p http://www.domain.com/folder/
2009-12-27 05:23:27
User: svnlabs
Functions: wget

wget ? server to server files transfer