A quick way to get a MD5 hash of a string in Linux CLI

the simples way to get a MD5 hash of a string that I found is:

md5sum<<<putYourWordHere

this should print:

074d876a127bc3344f9c3c72cefac56d  -

Unfortunately this will print the hash followed by trailing two spaces and a dash.
To get rid of them, simply pipe the output to the cut command:

md5sum<<<putYourWordHere | cut -f1 -d' '

this will print the hash without that trailing garbage

074d876a127bc3344f9c3c72cefac56d

Finally, if you'd like to convert it into a bash command, the add this function to you .bashrc file

# will calculate md5sum from a input string
# example 1: md5 "this is a long string test_string"
# example 2: md5 singleWordExample
function md5() { md5sum<<<$1 | cut -f1 -d' '; }

How to install Groovy on Ubuntu, Linux Mint and other similar distros

A short tutorial how to install Groovy on Ubuntu, Linux Mint and other similar distros.

Download lastest Groovy build @ http://groovy.codehaus.org/Download and upack it

First create a groovy folder in /usr/lib

sudo mkdir /usr/lib/groovy

Then move the unpacked groovy folder to it

sudo mv groovy-1.8.6/ /usr/lib/groovy/

Our next step is to use update-alternatives to add a group of alternatives to the system

sudo update-alternatives --install "/usr/bin/groovy" "groovy" "/usr/lib/groovy/groovy-1.8.6/bin/groovy" 1
sudo update-alternatives --install "/usr/bin/groovyc" "groovyc" "/usr/lib/groovy/groovy-1.8.6/bin/groovyc" 1
sudo update-alternatives --install "/usr/bin/groovyConsole" "groovyConsole" "/usr/lib/groovy/groovy-1.8.6/bin/groovyConsole" 1
sudo update-alternatives --install "/usr/bin/groovysh" "groovysh" "/usr/lib/groovy/groovy-1.8.6/bin/groovysh" 1
sudo update-alternatives --install "/usr/bin/java2groovy" "java2groovy" "/usr/lib/groovy/groovy-1.8.6/bin/java2groovy" 1

Then to check if everything is fine:

sudo update-alternatives --config groovy

and finally

groovy -v

should give you:

Groovy Version: 1.8.6 JVM: 1.6.0_27 Vendor: Sun Microsystems Inc. OS: Linux

Lastly try groovyConsole for evaluating your Groovy script:

groovyConsole

ps. I used this tutorial how to install oracle java 7 as a basis for this one 🙂

Ta-dah! you’re done 🙂