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





Commands by totti from sorted by
Terminal - Commands by totti - 87 results
ls -i1 filename
tail -f ~/.bash_history
2011-09-15 19:35:09
User: totti
Functions: tail
Tags: watch

Changes are displayed when they are written to the file

to exit

vi +4 /etc/mtab
2011-09-15 19:18:00
User: totti
Functions: vi
Tags: edit text line goto

This is not printing, real editing using the text editor.

awk '$3==$4' /etc/passwd
sed 's/.$//' Win-file.txt
cat aaaaaa 2>&-
nl file.txt > file_numbered.txt
var='123456789'; echo ${var:<start_pos>:<offset>}
2011-09-14 20:05:17
User: totti
Functions: echo

substrings a variable starting at position.

If no offset given prints rest of the line

c=$(pgrep <cmd>) && <new_cmd> && kill $c
2011-09-14 19:58:30
User: totti
Functions: kill


Already running cmd

sleep 120

Substitution cmd

c=$(pgrep sleep) && sleep 5 && kill $c
bsdiff <oldfile> <newfile> <patchfile>
2011-09-13 18:22:40
User: totti

Upload/download newer version of any file with less size and high speed.

To remake the new file use

bspatch <oldfile> <newfile> <patchfile>
less file.ext
2011-09-13 10:29:27
User: totti
Functions: less
Tags: less text search

Use the following key binding to search



: Jump to line number n. Default is the start of the file.


: Jump to line number n. Default is the end of the file.


: Search for pattern. Regular expressions can be used. [/ = slash] Press / and then Enter to repeat the previous search pattern. Press ESC and then u to undo search highlighting.


: Go to next match (after a successful search).


: Go to previous match.


: Mark the current position with letter.


: Return to position letter. [' = single quote]

'^ or g

: Go to start of file.

'$ or G

: Go to end of file.


: Save current content (got from another program like grep) in a file.

= or Ctrl+g

: File information.


: continually read information from file and follow its end. Useful for logs watching. Use Ctrl+c to exit this mode.


: Toggle command-line option -option.


: Help.

smartctl -A /dev/sda | grep Power_On_Hours
tr -d "\r" < file.vcf | tr "\0" " " > file.vcf.txt
tr -d "\r" < dos.txt > linux.txt
mogrify -resize 600x800! *.jpg
2011-09-09 18:19:59
User: totti

- Backup data before reszie as it over write original

-To preserve aspect ratio remove !

hexdump -c <file>
say() { wget -q -U Mozilla -O output.mp3 "http://translate.google.com/translate_tts?tl=en&q=$1"; gnome-terminal -x bash -c "totem output.mp3"; sleep 4; totem --quit;}
2011-09-07 19:48:53
User: totti
Functions: bash sleep wget

No need to install additional packages


say hello

For multiword

say how+are+you

<Ctrl><Alt><F6> killall5
2011-09-07 19:19:34
User: totti

Killall5 will kill your session and redirect to login screen.

-Very useful when suffering display problems.

-Can use F1-F6

-Need to login in the particular console if not already

wallpaperWarn() { BG="/desktop/gnome/background/picture_filename"; convert "`gconftool-2 -g $BG`" -pointsize 70 -draw "gravity center fill red text 0,-360 'Warn' fill white text 0,360 'Warn'" /tmp/w.jpg; gconftool-2 --set $BG -t string "/tmp/w.jpg"; }
2011-09-07 19:00:40
User: totti

Display some text on the wallpaper especially warning messages

convert -background none -pointsize 55 label:"`whoami`" me.png
2011-09-07 17:06:38
User: totti

Create transparent image to use as icon, watermark for other images, etc.

sed '4!d'
2011-09-05 17:54:57
User: totti
Functions: sed

d --> delete

!d ---> delete others

bc <<< `uptime | sed -e 's/^.*up //' -e 's/[^0-9:].*//' | sed 's/:/*60+/g'`
2011-08-29 10:24:43
User: totti
Functions: bc sed

Want to run scripts/programs in the system after starting X minute [ For letting the system to free ]? This will give uptime in minute.

seq 20 | sed '5,6 { w out.txt }' #Can't print correctly. See sample output
2011-08-29 10:17:47
User: totti
Functions: sed seq
Tags: sed

Can't print correctly in the command field.

There is a new line before } as follows

seq 20 | sed -n '5,6 { w out.txt


mount |tail -1 | less -p "/dev/[^ ]*"
switchMonitor () { LF=/tmp/screen-lock; if [ -f $LF ]; then rm $LF; else touch $LF; sleep .5; while [ -f $LF ]; do xset dpms force off; sleep 2; done; fi };
2011-08-26 17:55:44
User: totti
Functions: rm sleep touch

Use the command to create a script and bind it to a key using keyboard shortcut.


Script locks the screen in a loop until the command is executed again.At first it