{"id":12309,"date":"2021-11-24T04:59:39","date_gmt":"2021-11-24T04:59:39","guid":{"rendered":"https:\/\/linuxways.net\/?p=12309"},"modified":"2021-11-24T04:59:39","modified_gmt":"2021-11-24T04:59:39","slug":"set-up-automatic-unattended-updates-for-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/set-up-automatic-unattended-updates-for-ubuntu-20-04\/","title":{"rendered":"Set Up Automatic Unattended Updates for Ubuntu 20.04"},"content":{"rendered":"<p>Regularly updating your server is a crucial aspect to the overall security of your system. Sysadmins must be concerned about the security of Linux servers. Installing security updates on time fixes vulnerabilities that could be exploited by malicious individuals to gain access to the system.<\/p>\n<p>Manually updating your Linux system is a task that&#8217;s easy to overlook, especially when you&#8217;re always dealing with other issues that arise. Configuring automatic updates provides an easy way to get the security patches and feature updates regularly.<\/p>\n<p>This guide will discuss how to enable automatic updates on Ubuntu 20.04.<\/p>\n<h2><strong>Step 1: Install unattended-upgrades package<\/strong><\/h2>\n<p>The unattended-upgrades package allows you to configure automatic updates. The package ensures that your system is up to date on all security and feature upgrades.<\/p>\n<p>First, lets install the unattended-upgrades package via the apt package manager as shown:<\/p>\n<pre><strong>$ sudo apt install unattended-upgrades<\/strong><\/pre>\n<p>Next, confirm the package was installed using the following <a href=\"https:\/\/linoxide.com\/linux-systemd-commands\/\">systemctl command<\/a>:<\/p>\n<pre><strong>$ sudo systemctl status unattended-upgrades<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"237\" class=\"wp-image-12310\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-440.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-440.png 960w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-440-300x74.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-440-768x190.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/strong><\/p>\n<p>The unattended-upgrades service is now up and running.<\/p>\n<p>Next, let\u2019s install the update-notifier-common package to enable automatic updates.<\/p>\n<pre><strong>$ sudo apt install update-notifier-common<\/strong><\/pre>\n<h2><strong>Step 2: Configure unattended-upgrades service<\/strong><\/h2>\n<p>Now let\u2019s make changes to the unattended-upgrades configuration file.<\/p>\n<p>This file allows you to specify which packages should automatically be updated or excluded during the update process. By default, only security updates are set to be automatically installed.<\/p>\n<pre><strong>$ sudo vim \/etc\/apt\/apt.conf.d\/50unattended-upgrades<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"953\" height=\"785\" class=\"wp-image-12311\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-441.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-441.png 953w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-441-300x247.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-441-768x633.png 768w\" sizes=\"auto, (max-width: 953px) 100vw, 953px\" \/><\/p>\n<p>The configurations in the file are commented using the double slash (\/\/). Uncomment or remove the double slash if you want to update a repository or make changes in your settings.<\/p>\n<p>To exclude a package from being updated, include it in the <strong>Unattended-Upgrade::Package-Blacklist<\/strong> section. For example, to prevent Nginx from being updated, include the name as shown below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"868\" height=\"204\" class=\"wp-image-12312\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-442.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-442.png 868w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-442-300x71.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-442-768x180.png 768w\" sizes=\"auto, (max-width: 868px) 100vw, 868px\" \/><\/p>\n<h2><strong>Step 3: Set up email notifications<\/strong><\/h2>\n<p>It&#8217;s a good idea to set up e-mail notifications, especially if you&#8217;re running unattended servers. You can also select &#8220;only-on-error&#8221; to receive notifications only when there is an error. Locate the line below to set up an email.<\/p>\n<pre><strong>\/\/Unattended-Upgrade::Mail \" \";<\/strong><\/pre>\n<p>Make sure to provide the email address of the receiver.<\/p>\n<pre><strong>Unattended-Upgrade::Mail \"me@example.com \";<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"766\" height=\"109\" class=\"wp-image-12313\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-443.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-443.png 766w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-443-300x43.png 300w\" sizes=\"auto, (max-width: 766px) 100vw, 766px\" \/><\/strong><\/p>\n<p>In addition, you can also select &#8220;only-on-error&#8221; to receive notifications only when there is an error. Selecting email &#8220;on-change&#8221; in the configuration file allows you to receive notifications when software changes.<\/p>\n<p>Uncomment the following line and change it according to your preferences. <strong>\/\/Unattended-Upgrade::MailReport &#8220;on-change&#8221;;<\/strong><\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"784\" height=\"115\" class=\"wp-image-12314\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-444.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-444.png 784w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-444-300x44.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-444-768x113.png 768w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/strong><\/p>\n<h2><strong>Step 4: Enable Automatic Reboot<\/strong><\/h2>\n<p>It&#8217;s always a good idea to restart the server after applying security updates so that the kernel can be updated. You can activate an automated reboot in the line shown below:<\/p>\n<pre><strong>\/\/Unattended-Upgrade::Automatic-Reboot \"false\";<\/strong><\/pre>\n<p>Set it to true to enable automatic reboot.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"830\" height=\"83\" class=\"wp-image-12315\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-445.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-445.png 830w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-445-300x30.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-445-768x77.png 768w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/strong><\/p>\n<p>If there are any users logged in and you still want to reboot locate the following line and set it to true&#8221;<\/p>\n<pre>\/\/ Unattended-Upgrade::Automatic-Reboot-WithUsers \"true\";<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"713\" height=\"82\" class=\"wp-image-12316\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-446.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-446.png 713w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-446-300x35.png 300w\" sizes=\"auto, (max-width: 713px) 100vw, 713px\" \/><\/p>\n<p>You can specify the time the automatic reboot will occur.<\/p>\n<pre><strong>\/\/ Unattended-Upgrade::Automatic-Reboot-Time \"04:00\";<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"767\" height=\"94\" class=\"wp-image-12317\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-447.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-447.png 767w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-447-300x37.png 300w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><\/p>\n<p>There are many other settings you can change to suit your needs. Simply uncomment them as we have discussed in this section.<\/p>\n<p>Once you are done, save the changes and exit the configuration file.<\/p>\n<h2><strong>Step 5: Enable automatic updates <\/strong><\/h2>\n<p>In this step we will enable automatic upgrades. Edit the <strong>20auto-upgrades <\/strong>configuration file as follows:<\/p>\n<pre><strong>$ sudo vim \/etc\/apt\/apt.conf.d\/20auto-upgrades<\/strong><\/pre>\n<p>This file has only two lines as shown.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"729\" height=\"488\" class=\"wp-image-12318\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-448.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-448.png 729w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-448-300x201.png 300w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><\/p>\n<p>The first line is responsible for updating the package lists, while the second initiates the automated upgrades. The auto-update and auto-upgrade are enabled by the value &#8220;1.&#8221; Set this value to &#8220;0&#8221; if you wish to disable it.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>You have successfully configured Ubuntu 20.04 to receive automatic updates. You can be confident that your packages will always be updated.<\/p>","protected":false},"excerpt":{"rendered":"<p>Regularly updating your server is a crucial aspect to the overall security of your system. Sysadmins must be concerned about the security of Linux servers. Installing security updates&hellip;<\/p>","protected":false},"author":1,"featured_media":12396,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[100,698],"class_list":["post-12309","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-ubuntu-20-04","tag-updates"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/12309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=12309"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/12309\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/12396"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=12309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=12309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=12309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}