stefan's blag and stuff

Blog – 2016-02-06 – Auto-upgrades on Debian

Keeping your system up to date can sometimes be very time consuming. It's better to just install the recent security updates automatically and get informed by these events. The following commands install the debian package unattended-upgrades and enables email notifications. They are taken from UnattendedUprades in the Debian Wiki, but without apt-listchanges since it's not needed for these upgrades in the first place.

# Install unattended-upgrades
$ sudo -s	                # Get root for all commands
$ cat /etc/issue                # Print debian version. It's jessie.
Debian GNU/Linux 8 \n \l
$ apt-get install unattended-upgrades
$ vim /etc/apt/apt.conf.d/50unattended-upgrades   # enable mail to root
$ cat /etc/apt/apt.conf.d/50unattended-upgrades
// 2016-01-31 enabled by stc to get reports about package upgrades
Unattended-Upgrade::Mail "root";
# Check if mail to "root" is forwarded to your email account correctly
# (We have our mails accounts on the same server, but it can also be forwared
# to another address/server)
$ cat /etc/aliases              # check forward settings for root account
root: user1, user2
$ echo "test body" | mail -s "test" root       # and then check your inbox

# Create config file /etc/apt/apt.conf.d/20auto-upgrades
$ dpkg-reconfigure -plow unattended-upgrades   # and answer the question with 'yes'
$ cat /etc/apt/apt.conf.d/20auto-upgrades      # check settings
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

# Now wait for the first email.