Hide

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.

Hide

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:

Hide

News

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.
Hide

Tags

Hide

Functions

Commands using gpg from sorted by
Terminal - Commands using gpg - 36 results
gpg --allow-multiple-messages --decrypt-files *
2009-09-20 11:50:41
User: bkn390
Functions: gpg
1

Change directory (cd) to the directory where all your encrypted files are placed, and then run the command - then you are asked to insert your secret gpg password - ubuntu 8.04

echo "SECRET MESSAGE" | gpg -e --armor -s | sendmail USER@DOMAIN.COM
2009-09-04 20:47:12
User: flip387
Functions: echo gpg sendmail
3

A very simple command to send a signed and encrypted message from the command line using GPG Keys

gpg --search-keys
eval $(sed -n "s/^d[^D]*DB_\([NUPH]\)[ASO].*',[^']*'\([^']*\)'.*/_\1='\2'/p" wp-config.php) && mysqldump --opt --add-drop-table -u$_U -p$_P -h$_H $_N | gpg -er AskApache >`date +%m%d%y-%H%M.$_N.sqls`
2009-08-18 07:03:08
User: AskApache
Functions: eval gpg sed
3

The coolest way I've found to backup a wordpress mysql database using encryption, and using local variables created directly from the wp-config.php file so that you don't have to type them- which would allow someone sniffing your terminal or viewing your shell history to see your info.

I use a variation of this for my servers that have hundreds of wordpress installs and databases by using a find command for the wp-config.php file and passing that through xargs to my function.

curl -s http://defekt.nl/~jelle/pubkey.asc | gpg --import
2009-06-18 11:26:03
User: wires
Functions: gpg
2

imports a public key from the web. I know this by head.. but useful nevertheless

tar -cf - folder/ | gpg -c > folder.tpg
2009-05-08 19:20:08
User: copremesis
Functions: gpg tar
-1

gpg's compression is as suitable as gzip's however your backups can now be encrypted.

to extract use:

gpg < folder.tpg | tar -xf -
tr -dc "a-zA-Z0-9-_\$\?" < /dev/urandom | head -c 10 | gpg -e -r medha@nerdish.de > password.gpg
2009-02-25 08:48:26
User: hans
Functions: gpg head tr
2

Adjust the

head -c

part for password length.

I use filenames like "hans@commandlinefu.com.gpg" and a vim which automatically decrypts files with .gpg suffixes.

gpg --encrypt --recipient 'Foo Bar' foo.txt
2009-02-16 19:58:13
User: mariusz
Functions: gpg
4

gpg command to encrypt a file on the command line.

gpg --output foo.txt --decrypt foo.txt.pgp
2009-02-16 19:56:19
User: mariusz
Functions: gpg
5

gpg command to decrypt a previously encrypted file on the command line.

Can be optionally made into an alias:

alias decrypt='gpg --output foo.txt --decrypt foo.txt.pgp'

for x in *.pgp do `cat /file_with_the_passphrase.dat|(gpg --batch --no-tty --yes --passphrase-fd=0 --decrypt `basename $x`; ) > 'dump_content.dat'` done;
gpg --keyserver pgp.surfnet.nl --recv-key 19886493
2009-02-06 02:24:28
User: liupeng
Functions: gpg
3

get my GPG-key from pgp.surfnet.nl, key id is 19886493.