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

Encrypt and password-protect execution of any bash script

Terminal - Encrypt and password-protect execution of any bash script
echo "eval \"\$(dd if=\$0 bs=1 skip=XX 2>/dev/null|gpg -d 2>/dev/null)\"; exit" > script.secure; sed -i s:XX:$(stat -c%s script.secure): script.secure; gpg -c < script.bash >> script.secure; chmod +x script.secure
2013-03-09 11:16:48
User: rodolfoap
Functions: chmod echo gpg sed stat
6
Encrypt and password-protect execution of any bash script

(Please see sample output for usage)

script.bash is your script, which will be crypted to script.secure

script.bash --> script.secure

You can execute script.secure only if you know the password. If you die, your script dies with you.

If you modify the startup line, be careful with the offset calculation of the crypted block (the XX string).

Not difficult to make script editable (an offset-dd piped to a gpg -d piped to a vim - piped to a gpg -c directed to script.new ), but not enough space to do it on a one liner.

Alternatives

There is 1 alternative - vote for the best!

Terminal - Alternatives
read -p 'Script: ' S && C=$S.crypt H='eval "$((dd if=$0 bs=1 skip=//|gpg -d)2>/dev/null)"; exit;' && gpg -c<$S|cat >$C <(echo $H|sed s://:$(echo "$H"|wc -c):) - <(chmod +x $C)
2013-03-10 08:59:45
User: rodolfoap
Functions: cat chmod echo gpg read sed wc
7

(Please see sample output for usage)

Use any script name (the read command gets it) and it will be encrypted with the extension .crypt, i.e.:

myscript --> myscript.crypt

You can execute myscript.crypt only if you know the password. If you die, your script dies with you.

If you modify the startup line, be careful with the offset calculation of the crypted block (the XX string).

Not difficult to make script editable (an offset-dd piped to a gpg -d piped to a vim - piped to a gpg -c directed to script.new ), but not enough space to do it on a one liner.

Sorry for the chmod on parentheses, I dont like "-" at the end.

Thanks flatcap for the subshell abbreviation to /dev/null

Know a better way?

If you can do better, submit your command here.

What others think

Nicely done !

Comment by erix 89 weeks and 4 days ago

Welcome to my Taobao shop !

Daily update:

Discover amazing stuff, collect the things you love, buy it all in one place.

novel style, varieties, low price and good quality, and the low sale price

==== ( http://www.fullmalls.com ) =====

==== ( http://www.fullmalls.com ) =====

New to Hong Kong : Winter Dress

Best quality, Best reputation , Best services

---**** NHL Jersey Woman $ 40 ---**** NFL Jersey $ 35

---**** NBA Jersey $ 34 ---**** MLB Jersey $ 35

---**** Jordan Six Ring_m $ 36 ---**** Air Yeezy_m $ 45

---**** T-Shirt_m $ 25 ---**** Jacket_m $ 36

---**** Hoody_m $ 50 ---**** Manicure Set $ 20

---**** handbag $ 37 ---**** ugg boot $ 43 ---****

give you the unexpected harvest

==== ( http://www.fullmalls.com ) =====

==== ( http://www.fullmalls.com ) =====

==== ( http://www.fullmalls.com ) =====

==== ( http://www.fullmalls.com ) =====

Comment by yeiuoisdf 89 weeks and 4 days ago

Your command is wrong.

Hint: What is script.bash?

Comment by betsubetsu 89 weeks and 3 days ago

betsu{,} : click on Sample Output with the right button of your mouse and you see how to use the command. You need some input script to encrypt, in the example, script.bash.

Comment by rodolfoap 89 weeks and 3 days ago

very good, I like it

Comment by liuwei000000 88 weeks and 6 days ago

Your point of view

You must be signed in to comment.

Related sites and podcasts