Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Distributions»Debian»How to Install Security Updates in Ubuntu & Debian

    How to Install Security Updates in Ubuntu & Debian

    RahulBy RahulJuly 9, 20163 Mins ReadUpdated:June 9, 2021

    Updating the software packages is an essential part of any operating system. It’s hard to keep track of all the security on your systems. The easiest way is to keep your Ubuntu system secure by updating software packages regularly.

    In this tutorial, we will discuss two methods, manual and automatic to keep packages up to date. The Ubuntu system provides unattended-upgrades option to install security updates on your systems. You can also configure your system to install security updates automatically.

    Installing Security Updates Manually

    Login to your Ubuntu or Debian system with Sudo privileged account. Open a terminal on your system and execute the following command to update the apt cache.

    sudo apt update 
    

    Next, find all the packages upgrades available for your system.

    sudo apt list --upgradable 
    
    Check Available Package Upgrades on Ubuntu
    Check Available Package Upgrades on Ubuntu

    See the above list of packages, which is going to upgrade.

    Now, execute the following command to install updates all packages.

    sudo apt upgrade 
    
    Install Package Upgrades on Ubuntu
    Install Package Upgrades on Ubuntu

    When prompted for the confirmation, Press ‘y’ and hit enter to complete the installation process.

    The non-production users can also run the dist-upgrade command to upgrade those packages, which are not upgraded with the above commands. We are not recommending this in the production environment as the server may face issues for version-specific applications.

    sudo apt dist-upgrade 
    

    Before applying on production, make an ideal environment (Eg: copy of instance) of production and test it first.

    Install Security Updates Automatically

    The unattended-upgrades package helps to keep the computer current with the latest security (and other) updates automatically.

    Default unattended-upgrades package should be installed on your system. But in case it’s not installed use the following command to install.

    sudo apt install unattended-upgrades apt-listchanges
    

    You can simply execute the following command to install security updates on your system. The below command will run silently on your system and apply security updates.

    sudo dpkg-reconfigure unattended-upgrades 
    
    Setup unattended-upgrades Ubuntu & Debian
    Setup unattended-upgrades Ubuntu & Debian

    Select “Yes” and hit enter to complete the configuration.

    The above command will create /etc/apt/apt.conf.d/20auto-upgrades configuration file with required settings.

    Additionally, You can also run the unattended-upgrades command manually to perform packages upgrades.

    sudo unattended-upgrades -d 
    

    The -d command line options show verbose logs of the update process.

    For the review purpose, the unattended upgrade log files can be find under /var/log/unattended-upgrades/ directory. It is good to review this file with the periodic system maintenance.

    Remove Unnecessary Packages

    Ubuntu keep track of all the packages, which is no longer removed. These are the packages which was installed as decencies of other packages and that package is removed from system.

    Apt package manager provides you option to remove that packages from system.

    sudo apt autoremove 
    

    Conclusion

    In this tutorial, you have learned two methods of upgrading security updates on Ubuntu and Debian systems.

    packages security Updates
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install Grunt on CentOS/RHEL 7/6/5
    Next Article Key Features of a Good E-commerce Website

    Related Posts

    Changing the Login Screen Background in Ubuntu 22.04 & 20.04

    Updated:May 9, 20222 Mins Read

    (Resolved) Please install all available updates for your release before upgrading

    2 Mins Read

    How to Install LightDM Display Manager on Ubuntu

    Updated:May 10, 20222 Mins Read

    Change Screen Resolution of An Ubuntu VM in Hyper-V

    Updated:May 2, 20222 Mins Read

    How to Check IPv4 Address on Ubuntu 22.04

    2 Mins Read

    How to Configure Static IP Address on Ubuntu 22.04

    Updated:May 4, 20223 Mins Read

    3 Comments

    1. Robi Erwin Setiawan on December 22, 2020 11:04 pm

      The update will be automatically restart the server or not?

      Reply
      • Rahul on June 1, 2021 4:39 pm

        No, it will not restart server

        Reply
      • Nishant on June 2, 2021 5:18 am

        For automatic restart of the server after an upgrade, you can do the below settings.

        go to in this file: /etc/apt/apt.conf.d/50unattended-upgrades

        Here you will see these commented lines.

        ***********************
        // Automatically reboot even if there are users currently logged in
        // when Unattended-Upgrade::Automatic-Reboot is set to true
        //Unattended-Upgrade::Automatic-Reboot-WithUsers “true”;

        // If automatic reboot is enabled and needed, reboot at the specific
        // time instead of immediately
        // Default: “now”
        //Unattended-Upgrade::Automatic-Reboot-Time “02:00”;
        **********************

        You can enable the below line, your server will be rebooted after upgrades when needed.

        Unattended-Upgrade::Automatic-Reboot-WithUsers “true”;

        or if you want to reboot the server at a specific time, then enable the below line and set the time:

        Unattended-Upgrade::Automatic-Reboot-Time “02:00”;

        Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.