{"id":21185,"date":"2023-09-27T11:00:15","date_gmt":"2023-09-27T11:00:15","guid":{"rendered":"https:\/\/linuxways.net\/?p=21185"},"modified":"2023-09-27T11:00:15","modified_gmt":"2023-09-27T11:00:15","slug":"how-to-configure-automatic-security-updates-on-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-configure-automatic-security-updates-on-ubuntu-22-04\/","title":{"rendered":"How to Configure Automatic Security Updates on Ubuntu 22.04?"},"content":{"rendered":"<p>Ubuntu releases software updates, security patches, and other critical updates quite frequently. Manually checking for updates and updating the system can become a tedious task and there are chances of missing important updates which can be critical. The user must ensure that Linux machines are updated with the latest \u201c<strong>security updates<\/strong>\u201d.<\/p>\n<p>In this article, the setting up of automatic security updates on Ubuntu 22.04 LTS will be discussed.<\/p>\n<h2><a id=\"post-21185-_ljks07h0rocp\"><\/a>Prerequisites<\/h2>\n<p>In order to follow this article, we will require<\/p>\n<ul>\n<li>System with Ubuntu 22.04 LTS Installed.<\/li>\n<li>A user account with sudo privileges.<\/li>\n<li>A text editor (e.g., Nano)<\/li>\n<\/ul>\n<h2><a id=\"post-21185-_vwi4ezl9toa3\"><\/a>How to Configure\/ Set up Automatic Security Updates on Ubuntu 22.04?<\/h2>\n<p><strong>Security updates<\/strong> are regularly released by operating systems including Linux Ubuntu. Security updates resolve the issue(s) that impact the Operating System\u2019s performance. The following steps will be performed in order to set up automatic security updates on Ubuntu:<\/p>\n<h3><a id=\"post-21185-_k2smca5bupbm\"><\/a>Step 1: Update System Repositories<\/h3>\n<p>We will update existing packages by running the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> apt update<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"613\" class=\"wp-image-21186\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-1.png 2048w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-1-300x90.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-1-1024x307.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-1-768x230.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-1-1536x460.png 1536w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<h3><a id=\"post-21185-_kjyce8nfyyzm\"><\/a>Step 2: Install unattended-upgrades Package<\/h3>\n<p>The purpose of the \u201cunattended-upgradeds\u201d package is to keep the computer up to date with software updates, security patches, and other critical updates. We will install the unattended-upgrade package using the below command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> unattended-upgrades<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"495\" class=\"wp-image-21187\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-2.png 2048w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-2-300x73.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-2-1024x248.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-2-768x186.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-2-1536x371.png 1536w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<p>From the above screenshot, it can be seen that the unattended-upgrade package is installed successfully. We can verify the status of unattended-upgrades by using the below command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span>systemctl status unattended-upgrades<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"847\" class=\"wp-image-21188\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-3.png 2048w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-3-300x124.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-3-1024x424.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-3-768x318.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-3-1536x635.png 1536w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<p>As seen from the above screenshot, the status of the unattended-upgrades package is \u201cactive (running)\u201c.<\/p>\n<h3><a id=\"post-21185-_li842yf2egnd\"><\/a>Step 3: Enable the unattended-upgrades Function<\/h3>\n<p>We will run the below command to enable the unattended-upgraded function:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> dpkg-reconfigure <span class=\"re5\">--priority<\/span>=low unattended-upgrades<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1956\" height=\"156\" class=\"wp-image-21189\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-4.png 1956w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-4-300x24.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-4-1024x82.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-4-768x61.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-4-1536x123.png 1536w\" sizes=\"auto, (max-width: 1956px) 100vw, 1956px\" \/><\/p>\n<p>After running this command, we will be prompted for a sudo password, After that, we will be guided to the configuration wizard:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1952\" height=\"1022\" class=\"wp-image-21190\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-5.png 1952w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-5-300x157.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-5-1024x536.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-5-768x402.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-5-1536x804.png 1536w\" sizes=\"auto, (max-width: 1952px) 100vw, 1952px\" \/><\/p>\n<p>Click \u201c<strong>Yes<\/strong>\u201d and press Enter. As a result, a new file will be created at the following path: \u201cfile \/etc\/apt\/apt.conf.d\/20auto-upgrades\u201d.<\/p>\n<h3><a id=\"post-21185-_dytn2j4mp84p\"><\/a>Step 4: Configure unattended-upgrade for Security Updates<\/h3>\n<p>We can configure the update options in the file at path: \/etc\/apt\/apt.conf.d\/50unattended-upgrades as follows:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>apt<span class=\"sy0\">\/<\/span>apt.conf.d<span class=\"sy0\">\/<\/span>50unattended-upgrades<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1942\" height=\"54\" class=\"wp-image-21191\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-6.png 1942w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-6-300x8.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-6-1024x28.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-6-768x21.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-6-1536x43.png 1536w\" sizes=\"auto, (max-width: 1942px) 100vw, 1942px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1946\" height=\"1020\" class=\"wp-image-21192\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-7.png 1946w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-7-300x157.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-7-1024x537.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-7-768x403.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-7-1536x805.png 1536w\" sizes=\"auto, (max-width: 1946px) 100vw, 1946px\" \/><\/p>\n<p>The above screenshot shows the default setup which indicates that security updates will be installed automatically. Security updates are crucial and are sufficient to keep the server up and running.<\/p>\n<h2><a id=\"post-21185-_tf0kcdf8okez\"><\/a>Bonus Tip 1: How to Set Up Normal Updates on Ubuntu?<\/h2>\n<p>If we would like to install normal updates automatically too, then we will edit the file and will un-comment the following line:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co1\">${distro_id}<\/span>:<span class=\"co1\">${distro_codename}<\/span><span class=\"re5\">-updates<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1960\" height=\"1022\" class=\"wp-image-21193\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-8.png 1960w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-8-300x156.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-8-1024x534.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-8-768x400.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-8-1536x801.png 1536w\" sizes=\"auto, (max-width: 1960px) 100vw, 1960px\" \/><\/p>\n<p>After updating the configuration, we will save and close the file by pressing Ctrl+O and Ctrl+X respectively:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1952\" height=\"1018\" class=\"wp-image-21194\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-9.png 1952w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-9-300x156.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-9-1024x534.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-9-768x401.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-9-1536x801.png 1536w\" sizes=\"auto, (max-width: 1952px) 100vw, 1952px\" \/><\/p>\n<h2><a id=\"post-21185-_gke8ufsidmxe\"><\/a>Bonus Tip 2: How to View Log Files?<\/h2>\n<p>Log files include all tasks done by the \u201cunattended-upgrades\u201d system. We can view the first 100 lines of the log file by running the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">tail<\/span> <span class=\"re5\">-n<\/span> <span class=\"nu0\">100<\/span> <span class=\"sy0\">\/<\/span>var<span class=\"sy0\">\/<\/span>log<span class=\"sy0\">\/<\/span>unattended-upgrades<span class=\"sy0\">\/<\/span>unattended-upgrades.log<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1950\" height=\"660\" class=\"wp-image-21195\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-10.png 1950w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-10-300x102.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-10-1024x347.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-10-768x260.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21185-10-1536x520.png 1536w\" sizes=\"auto, (max-width: 1950px) 100vw, 1950px\" \/><\/p>\n<p>The above screenshot shows details of all actions performed by the unattended upgrade system.<\/p>\n<h2><a id=\"post-21185-_k4r3ojha6hv3\"><\/a>Conclusion<\/h2>\n<p>In Ubuntu 22.04, automatic security updates are enabled by installing, enabling, and configuring \u201cunattended-upgrade\u201d packages. Security updates are critical for Ubuntu servers. Delaying to install security updates can result in unpleasant consequences. In this article, we have discussed detailed steps for setting up security updates automatically on Ubuntu. Setting up automatic updates can save us from unexpected situations as critical updates will be installed timely.<\/p>","protected":false},"excerpt":{"rendered":"<p>In Ubuntu 22.04, automatic security updates are enabled by installing, enabling, and configuring \u201cunattended-upgrade\u201d packages. <\/p>","protected":false},"author":110,"featured_media":21395,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-21185","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21185","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\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=21185"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21185\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/21395"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=21185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=21185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=21185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}