Skip to content

Instantly share code, notes, and snippets.

@mauvehed
Last active November 23, 2022 17:02
Show Gist options
  • Save mauvehed/3cfbca80eda7a532b2f8f846ea799f17 to your computer and use it in GitHub Desktop.
Save mauvehed/3cfbca80eda7a532b2f8f846ea799f17 to your computer and use it in GitHub Desktop.
Ubuntu - Enable Autoupdates

Execute the following command to update a server

sudo apt update && sudo apt upgrade

Now, install the unattended upgrade on your Ubuntu system through the following command:

sudo apt install unattended-upgrades apt-listchanges bsd-mailx

After that, turn on the unattended security updates by running the following command:

sudo dpkg-reconfigure -plow unattended-upgrades

After executing the command, configure the automatic update by executing the command given below:

sudo vi /etc/apt/apt.conf.d/50unattended-upgrades

Now, you can set up the alert email ID by the below command:

Unattended-Upgrade::Mail "xyz@abc.com";

In the above command, you can write your email ID instead of “xyz@abc.com”. In case you want automatically reboot the Ubuntu box without confirmation for the Kernel update, then use the following command:

Unattended-Upgrade::Automatic-Reboot "true";

Finally, you can edit the /etc/apt/listchanges.conf and set up the email ID:

email_address=xyz@abc.com

You can verify that the setup is working by executing the below command:

sudo unattended-upgrades --dry-run

The software updater in Ubuntu will also give you update when available. You only need to click on the update option, and the package will be automatically upgraded to a newer version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment