If you’ve been messing with Linux for a while you’ve no doubt seen screens like the above a million times. But for me it’s never been enough. If you have lots of boxes it’s possible to forget about them, so finding out that you have security updates when you log in isn’t proactive enough.
So let me save you 37 Googles. Here’s how to find out if your Ubuntu box needs security updates applied.
apt install update-notifier
/usr/lib/update-notifier/apt-check2>&1 | cut -d ‘;’ -f 2`
apt install ssmtp
Don’t forget to make the script executable.
SECUPDATES=/usr/lib/update-notifier/apt-check 2>&1 | cut -d ';' -f 2
if (( $SECUPDATES > 0 )); then ssmtp you@email.domain < echo "There are security updates oncat /etc/hostname
." | ssmtp -s "Updates oncat /etc/hostname
" else exit; fi
Now you will receive an email whenever your Ubuntu box has security updates available!