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,342 results
DISPLAY=":0.0" import -window root screenshot.png
2012-02-05 11:52:33
User: 0disse0
Tags: display

But if you use a screen saver, you must first disable your screen saver

kill $(ps ax | grep screensaver | grep -v grep | awk '{ print $1 }')

for a in $(cat sample.txt); do echo "${#a} $a";done|sort -n
SEED=$(head -1 /dev/urandom|od -N 1);for i in {1..10};do tmp=$(mkpasswd ${RANDOM});pass=${tmp:2:6};echo Pass $pass Crypt: $(mkpasswd $pass);done
cat *mscache* | awk -F '"' '{print $4":"$2}'
2013-01-06 06:54:57
User: mubix
Functions: awk cat

Convert Metasploit?s MSCACHE output to Hashcat version (performed in ~/.msf4/loot/):

grep -Po '^sub (\w+)' file.pm | cut -d' ' -f2
2013-03-07 12:31:34
Functions: cut grep

instead of printing the whole line, print just the capture matched, but with the "cut" pipe :( I'm so sad with grep.

emerge --moo
ls /EMRCV5/
rsync --recursive --info=progress2 <src> <dst>
2014-10-21 22:19:44
User: koter84
Functions: rsync
Tags: rsync progress

update the output of rsync after completing a file but don't create newlines, just overwrite the last line, this looks a lot better in scripts where you do want to see a progress-indicator, but not the lengthy logs

this option is available since rsync 3.1.0

using 3 thread to download some big file
touch -acm yyyymmddhhMM.ss [file]
2009-02-05 21:07:09
User: wwest4
Functions: touch

...changes modify time and access time. also:

touch -r [file1] [file2] # make file2 timestamp match file1

man fetchmail | perl -ne 'undef $/; print $1 if m/^.*?(-k \| --keep.*)-K \| --nokeep.*$/smg'
2009-06-25 23:51:35
Functions: fetchmail man perl

Using perl, here, we grep the man page of fetchmail to find the paragraph starting with '-k | --keep' and ending before the paragraph starting with '-K | --nokeep'

awk '{print substr($0, index($0,$N))}'
2009-08-31 19:47:10
User: mstoecker
Functions: awk

This command will print all fields from the given input to the end of each line, starting with the Nth field.

texmacs --delete-font-cache
2010-03-14 13:30:54
User: eastwind

after installing new fonts ( tfm , pfb , cjk , truetype ... ) manually in your ~/.Texmacs/fonts , it doesn't always reload it properly , just refresh it by delete the old cache fonts

in sample output , I just installed TrueType Chinese CJK fireflysung fonts supports

du -hs /path/to/target
bind '"\C-h": "\`fc\ \-s\`"'
2010-08-16 17:58:16
User: rthemocap

This is similar to using `!!` or

In bash 4.1 it seems you can bind directly to a shell command, but I'm not running that version.

sudo reflector -l 5 -r -o /etc/pacman.d/mirrorlist
2011-03-20 20:33:35
User: ibnarrashid
Functions: sudo

Requires 'reflector' package from official repository. '5' in the example is the number of mirrors you want in the mirrorlist, could be other numbers of course.

seq 1 1000000 | while read i; do echo -en "\r$i"; done
SUBNET="192.168.41" ; diff -y <(nmap -sP -n ${SUBNET}.0/24 | grep ${SUBNET}. | awk '{print $5}' | sort -t"." -k4 -n) <(for i in $(seq 1 254); do echo ${SUBNET}.$i; done)
2012-08-28 09:11:18
User: michel_p
Functions: awk diff echo grep seq sort

The command will make it easy to determine free IP ranges in a crowded sub-net.

machinfo | grep -i memory
2013-03-07 16:22:49
User: giorger
Functions: grep

Get the amount of physical memory in an HP-UX v11 OS when following are NOT available:

- root account

- no privileges in /proc

- no privileges in /dev/mem

for i in `pidof java`; do echo $i; ll /proc/$i; done;
2013-04-26 08:01:21
User: cuizhaohua
Functions: echo

list all java process info.

FOR /F "delims==" %%A IN ('type ips.txt') DO wmic /Node:%%A wmic /user:username /password:yourpassword /FAILFAST:ON process where "name like '%.exe'" call getowner
2014-06-26 01:53:29
User: operat0r
Tags: wmic hacking

This is used during pentest to quickly poll all the processes running on a set of systems you have common credentials for the /FAILFAST:ON speeds up the scans.

wait 536; anywait 536; anywaitd 537; anywaitp 5562 5563 5564
2014-10-22 06:31:47
User: colemar
Functions: wait


anywait () { for pid in "$@"; do while kill -0 "$pid" >/dev/null 2>&1; do sleep 0.5; done; done }

Prints dots:

anywaitd () { for pid in "$@"; do while kill -0 "$pid" >/dev/null 2>&1; do sleep 0.5; echo -n '.'; done; done }

Prints process ids:

anywaitp () { for pid in "$@"; do while kill -0 "$pid" >/dev/null 2>&1; do sleep 0.5; echo -n $pid' '; done; echo; done }

You cannot anywait for other users processes.

mysql -uadmin -p`cat /etc/psa/.psa.shadow` -e "use psa; select accounts.password from accounts INNER JOIN sys_users ON accounts.id=sys_users.account_id WHERE sys_users.login='xxxx';"
2009-02-18 17:26:41
User: darkon1365

This will print to the screen password for the user specified in "sys_users.login='xxxx';. This is for Plesk servers only.

mksnap_ffs /var /var/.snap/snap_var_`date "+%Y-%m-%d"` ; mdconfig -a -t vnode -f /var/.snap/snap_var_`date "+%Y-%m-%d"` -u 1; mount -r /dev/md1 /mnt
2010-09-18 11:37:03
User: bugmenot
Functions: mount


Once you've made the snapshot you can resume any stopped services and then back up the file system (using the snapshot) without having to worry about changed files.

When finished, the snapshot can be removed :

umount /mnt

mdconfig -d -u 1

rm /var/.snap/snap_var_`date "+%Y-%m-%d"`

println() {echo -n -e "\e[038;05;${2:-255}m";printf "%$(tput cols)s"|sed "s/ /${1:-=}/g"}
2011-01-09 18:08:18
User: joedhon
Functions: printf sed
Tags: sed tput printf

function for .bash_aliases that prints a line of the character of your choice in the color of your choice across the terminal.

Default character is "=", default color is white.