Commands by savagemike (1)

What's this? is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands

Check These Out

Clean way of re-running bash startup scripts.
This replaces the current bash session with a new bash session, run as an interactive non-login shell... useful if you have changed /etc/bash.bashrc, or ~/.bashrc If you have changed a startup script for login shells, use $ exec bash -l Suitable for re-running /etc/profile, ~/.bash_login and ~/.profile. edit: chinmaya points out that $ env - HOME=$HOME TERM=$TERM bash -s "exec bash -l" will clear any shell variables which have been set... since this verges on unwieldy, might want to use $ alias bash_restart='env - HOME=$HOME TERM=$TERM bash -s "exec bash -l"'

Recursively chmod all dirs to 755 and all files to 644

Capitalize first letter of each word in a string
Capitalize first letter of each word in a string.

Find how much of your life you've wasted coding in the current directory
Finds all C++, Python, SWIG files in your present directory (uses "*" rather than "." to exclude invisibles) and counts how many lines are in them. Returns only the last line (the total).

Install pip with Proxy
Installs pip packages defining a proxy

list block devices
Shows all block devices in a tree with descruptions of what they are.

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.bash --> You can execute 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 ), but not enough space to do it on a one liner.

Make a playlistfile for mpg321 or other CLI player
Supports other file formats.

Check your bash shell for vulnerability to the ShellShock exploit
If this command prints 'x' then your shell is vulnerable. Null output confirms that you are protected. Further reading:

Calculate days on which Friday the 13th occurs (inspired from the work of the user justsomeguy)
Friday is the 5th day of the week, monday is the 1st. Output may be affected by locale.

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.


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: