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:



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.

Top Tags



Commands by jasonjgw from sorted by
Terminal - Commands by jasonjgw - 13 results
~ ctrl-z
2010-11-21 07:43:40
User: jasonjgw

This must be typed before any other characters have been entered on the line. Use fg, as usual, to resume the ssh session.

fetchmail -p etrn --fetchdomains yourdomain.example.org secondary-server.example.org
2010-11-20 23:38:09
User: jasonjgw
Functions: fetchmail

This uses fetchmail to issue an etrn command that causes the MTA on the secondary mail server to process the queue for the specified domain.

You can also just use telnet or nc to connect to port 25 of the server and then:

etrn yourdomain.example.org

250 2.0.0 Queuing for node yourdomain.example.org started

find -L -type l
2010-11-20 07:59:58
User: jasonjgw
Functions: find

This is best run as root to avoid permission denials that can produce false positives.

Obviously you can specify a directory in the usual way:

find -L dirname -type l

I can't remember where I read about this or who deserves the credit for it. The find(1) manual page hints strongly toward it, however.

for f in * ; do [ -f $f ] && openssl enc -aes-256-cbc -salt -in $f -out $f.enc -pass file:/tmp/password-file ; done
2010-11-20 03:29:16
User: jasonjgw

The password is stored in the password file, which obviously must be kept secure, encrypted later with gpg, deleted, or whatever you prefer.

To decrypt:

openssl enc -d -aes-256-cbc -salt -in filename.enc -out filename -pass file:/path/to/password-file

Alternative ciphers can be used, of course.

exportfs -o fsid=0,rw :/home/jason
2010-11-18 10:02:52
User: jasonjgw

This exports a directory to the world in read/write mode. It is useful for

quick, temporary NFS exports. Consider restricting the clients to a subnet or

to specific hosts for security reasons (the client can be specified

before the colon).

On the client:

mount -t nfs4 hostname:/ /mountpoint

To terminate all of the exports (after unmounting on the client):

exportfs -u -a

Leave out the fsid=0 option if you don't want NFSv4.

This works under recent versions of Linux.

tar cfJ tarfile.tar.xz pathnames
2010-11-18 05:34:17
User: jasonjgw
Functions: tar

The J option is a recent addition to GNU tar. The xz compression utility is required as well.

ip addr change 2001:db8:1:2::ab dev eth0 preferred_lft 0
2010-11-18 05:05:15
User: jasonjgw

If two or more IPv6 addresses are assigned to an interface, apply this command to all but the address that you want to use as the source address of outbound packets.

This is Linux-specific and requires the iproute package, or equivalent for your distribution.

for f in *.doc ; do wvHtml $f ${f%.doc}.html ; done
2010-11-18 00:20:54
User: jasonjgw

This requires wvWare, which under Debian is in the wv package. Alternative converters can be used, e.g., jodconverter, which uses OO.O instead (no X server need be running.)

mv -i something.conf{,~} && sed "/regexp/s/^/#/" < something.conf~ > something.conf
tar cfz backup-$(date --iso).tar.gz somedirs
detex document.tex|wc -w