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 vlan7 from sorted by
Terminal - Commands by vlan7 - 12 results
mount -o remount,ro /dev/foo /
2010-10-30 03:51:53
User: vlan7
Functions: mount

Necessary for fsck for example.

The remount functionality follows the standard way how the mount command works with options from fstab. It means the mount command doesn't read fstab (or mtab) only when a device and dir are fully specified. After this call all old mount options are replaced and arbitrary stuff from fstab is ignored, except the loop= option which is internally generated and maintained by the mount command.

It does not change device or mount point.

sudo foremost -i /dev/sda -o /recovery
2010-08-19 22:27:41
User: vlan7
Functions: sudo

The above command assumes the lost data is on /dev/sda and you previously issued the following command to mount _another_ disk or partition (/dev/sdb1) on /recovery

sudo mount /dev/sdb1 /recovery

If you don't do this, the data could be overwrited!

foremost is a very powerful carving tool. By default foremost recovers all known file types. If you want to reduce the amount of files that are recovered you can specify the file type you are looking for. Read the man page to know the available file types.

i.e to recover JPEG pictures append to foremost the switch -tjpg

recode -l |less
2010-08-19 17:35:23
User: vlan7
Tags: convert

aliases on each line.



recode ..HTML <file.txt >file.html

txt to Base64:

recode ../b64 <file.txt >file.b64

and so on.

tar tfz filename.tgz |xargs rm -Rf
rpm2cpio package.rpm |cpio -dimv
2010-01-29 11:17:11
User: vlan7
Tags: trivia

Contrary to logic, typing calendar won't show a calendar, that's the job of cal.

Typing calendar will show some trivia related to the current date.

Tested against many Linux distros and FreeBSD.

emacs <ESC+x> doctor
a="www.commandlinefu.com";b="/index.php";for n in $(seq 1 7);do echo -en "GET $b HTTP/1.0\r\nHost: "$a"\r\n\r\n" |nc $a 80 2>&1 |grep Set-Cookie;done
2010-01-28 14:19:43
User: vlan7
Functions: echo grep seq
Tags: bash cookies

The loop is to compare cookies. You can remove it...

Maybe you wanna use curl...

curl www.commandlinefu.com/index.php -s0 -I | grep "Set-Cookie"
podwebserver& sleep 2; elinks ''
2010-01-27 10:57:34
User: vlan7
Functions: sleep

Prerequisites: module Pod::Webserver installed. You can install it typing:

sudo perl -MCPAN -e 'install Pod::Webserver'

You can replace elinks with your fav browser. For FF:

podwebserver& sleep 2; firefox -remote 'openurl(, new-tab )'

If you have Firefox open, this will pop-up the index web in a new tab.

for host in $(cat ftps.txt) ; do if echo -en "o $host 21\nquit\n" |telnet 2>/dev/null |grep -v 'Connected to' >/dev/null; then echo -en "FTP $host KO\n"; fi done
2010-01-26 15:34:18
User: vlan7
Functions: cat echo grep host telnet

I must monitorize a couple of ftp servers every morning WITHOUT a port-scanner

Instead of ftp'ing on 100 ftp servers manually to test their status I use this loop.

It might be adaptable to other services, however it may require a 'logout' string instead of 'quit'.

The file ftps.txt contains the full list of ftp servers to monitorize.

< /dev/rmt/0cbn
2010-01-25 20:32:38
User: vlan7
Tags: devices

Traditionally we rewind a tape using this syntaxis:

mt -f /dev/rmt/0cbn rewind

Redirecting the dispositive to nothing as shown above is faster. Less typing is always better.