How to Get Notified When Your Ubuntu Box Needs Security Updates

To benefit from the work I put into my typography, read natively at: How to Get Notified When Your Ubuntu Box Needs Security Updates.




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.



# Install apt-notifier to enable the check



apt install update-notifier



# Check to see how many security updates you have



/usr/lib/update-notifier/apt-check2>&1 | cut -d ‘;’ -f 2`



# Install ssmpt so you can send email from the command line



apt install ssmtp



# Then create a script in /etc/cron.hourly to check if there are updates available



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 on cat /etc/hostname." | ssmtp -s "Updates on cat /etc/hostname"
else
exit;
fi



Now you will receive an email whenever your Ubuntu box has security updates available!




I spend 5-20 hours a week collecting and curating content for the site. If you're the generous type and can afford fancy coffee whenever you want, please consider becoming a member at just $10/month.


Begin Membership



Stay curious,


Daniel

 •  0 comments  •  flag
Share on Twitter
Published on December 17, 2017 12:56
No comments have been added yet.


Daniel Miessler's Blog

Daniel Miessler
Daniel Miessler isn't a Goodreads Author (yet), but they do have a blog, so here are some recent posts imported from their feed.
Follow Daniel Miessler's blog with rss.