Change temporary directory in Linux

Sometimes, the size of / (root) mount is limited and in result some processes requiring large /tmp may fail. This can be solved by setting environmental variable TMPDIR:
[bash]
mkdir -p /home/$USER/tmp
TMPDIR=$(mktemp -d /home/$USER/tmp/XXXX)
TMP=$TMPDIR
TEMP=$TMPDIR
export TMPDIR TMP TEMP
[/bash]

More info on serverfault.

Advertisements

Sending emails from command-line using Gmail & SSMTP

I wanted to send email reports from my computers. For that, the easiest is to create additional Gmail account (so your private email is safe) and set-up SSMTP:

sudo apt-get install ssmtp mailutils mpack

Configure SSMTP: comment all lines in /etc/ssmtp/ssmtp.conf and add at the end (replacing HOSTNAME/USER/PASSWORD with your info):

hostname=HOSTNAME 
mailhub=smtp.gmail.com:587
AuthUser=USER@gmail.com
AuthPass=PASSWORD
FromLineOverride=YES
UseSTARTTLS=YES

Then, allow access from less secure apps to created Gmail account. It’s strongly recommended not to use your private account for that purpose!

And send emails:

echo "email body" | mail -s "Test email from "`hostname` SOMEUSER@gmail.com

VoilĂ !

Note, this works perfectly fine in Ubuntu, as well as in Raspberry Pi.