ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    How to configure automatic updates on Ubuntu 18.04 LTS

    IT Discussion
    ubuntu 18.04 automatic updates postfix unattended-upgrades
    6
    23
    2.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • IRJI
      IRJ
      last edited by IRJ

      First install unattended-upgrades and postfix

      sudo apt install unattended-upgrades
      sudo apt install postfix
      
      

      On postfix install select "Internet Site" and keep the default hostname in the next step.

      727862cf-5511-4402-ab54-9b51407c8b1e-image.png

      Next edit the 50unattended-upgrades file

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

      Now uncomment the following lines

      "${distro_id}:${distro_codename}-updates";
      
      Unattended-Upgrade::Mail "[email protected]";
      
      Unattended-Upgrade::Remove-Unused-Dependencies "true";
      
      

      There are some other options you can configure such as automatic reboots, but I decided not to do so.

      Now we need to configure /etc/apt/apt.conf.d/20auto-upgrades

      sudo nano /etc/apt/apt.conf.d/20auto-upgrades
      
      

      Paste the following text in /etc/apt/apt.conf.d/20auto-upgrades. The intervals below are set in days.

      APT::Periodic::Update-Package-Lists "1";
      APT::Periodic::Download-Upgradeable-Packages "1";
      APT::Periodic::AutocleanInterval "7";
      APT::Periodic::Unattended-Upgrade "1";
      
      

      Now save and test

      sudo unattended-upgrades
      
      

      You should get an email similar to this.

      Unattended upgrade returned: True
      
      Packages that were upgraded:
       
      
      Packages that were auto-removed:
       libutempter0 tmux python3-newt run-one net-tools pastebinit
      
      
      Package installation log:
      Log started: 2019-04-11  14:29:09
      Removing tmux (2.6-3ubuntu0.1) ...
      Removing libutempter0:amd64 (1.1.6-3) ...
      Processing triggers for libc-bin (2.27-3ubuntu1) ...
      Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
      Log ended: 2019-04-11  14:29:13
      
      Log started: 2019-04-11  14:29:14
      Removing python3-newt:amd64 (0.52.20-1ubuntu1) ...
      Log ended: 2019-04-11  14:29:16
      
      Log started: 2019-04-11  14:29:16
      Removing run-one (1.17-0ubuntu1) ...
      Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
      Log ended: 2019-04-11  14:29:20
      
      Log started: 2019-04-11  14:29:20
      Removing net-tools (1.60+git20161116.90da8a0-1ubuntu1) ...
      Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
      Log ended: 2019-04-11  14:29:23
      
      Log started: 2019-04-11  14:29:24
      Removing pastebinit (1.5-2) ...
      Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
      Log ended: 2019-04-11  14:29:28
      
      
      
      Unattended-upgrades log:
      Initial blacklisted packages:
      Initial whitelisted packages:
      Starting unattended upgrades script
      Allowed origins are: o=Ubuntu,a=bionic, o=Ubuntu,a=bionic-security, o=UbuntuESM,a=bionic, o=Ubuntu,a=bionic-updates
      Packages that will be upgraded:
      Packages that were successfully auto-removed: libutempter0 net-tools pastebinit python3-newt run-one tmux
      Packages that are kept back: 
      

      Script for anyone who is interested

      #***********************************************************
      # Install postfix and Unattended Upgrades
      #***********************************************************
      
      apt install -y unattended-upgrades
      apt install -y postfix
      
      #***********************************************************
      # Edit Config file
      #***********************************************************
      
      sed -i '/Unattended-Upgrade::Skip-Updates-On-Metered-Connections "true"/a\\Unattended-Upgrade::Mail "[email protected]";
      ' /etc/apt/apt.conf.d/50unattended-upgrades
      
      sed -i '/Unattended-Upgrade::Skip-Updates-On-Metered-Connections "true"/a\\Unattended-Upgrade::Remove-Unused-Dependencies "true";' /etc/apt/apt.conf.d/50unattended-upgrades
      
      sed -i '/Unattended-Upgrade::Skip-Updates-On-Metered-Connections "true"/a\\        "${distro_id}:${distro_codename}-updates";
      ' /etc/apt/apt.conf.d/50unattended-upgrades
      
      
      #***********************************************************
      # Create additonal config file
      #***********************************************************
      
      cat > /tmp/20auto-upgrades <<\EOF
      APT::Periodic::Update-Package-Lists "1";
      APT::Periodic::Download-Upgradeable-Packages "1";
      APT::Periodic::AutocleanInterval "7";
      APT::Periodic::Unattended-Upgrade "1";
      EOF
      
      #***********************************************************
      # Copy Config file
      #***********************************************************
      
      
      cp /tmp/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades
      rm /tmp/20auto-upgrades
      
      #***********************************************************
      # Enable and run Unattended-Upgrades
      #***********************************************************
      
      systemctl enable unattended-upgrades
      apt update
      unattended-upgrades
      
      dbeatoD wrx7mW 2 Replies Last reply Reply Quote 5
      • dbeatoD
        dbeato @IRJ
        last edited by

        @IRJ Awesome, I worked on this a few weeks ago so it is nice to see a tutorial.

        1 Reply Last reply Reply Quote 1
        • wrx7mW
          wrx7m @IRJ
          last edited by

          @IRJ Yay! Someone else that uses Nano.

          IRJI black3dynamiteB 2 Replies Last reply Reply Quote 1
          • IRJI
            IRJ @wrx7m
            last edited by

            @wrx7m said in How to configure automatic updates on Ubuntu 18.04 LTS:

            @IRJ Yay! Someone else that uses Nano.

            Thats one good thing about Ubuntu. Nano is included out of the box 😛

            1 Reply Last reply Reply Quote 0
            • black3dynamiteB
              black3dynamite
              last edited by

              Thank you for the how-to.
              I am too spoiled on how to configure auto updates for Fedora and CentOS.

              IRJI wrx7mW 2 Replies Last reply Reply Quote 2
              • IRJI
                IRJ @black3dynamite
                last edited by

                @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                Thank you for the how-to.
                I am too spoiled on how to configure auto updates for Fedora and CentOS.

                yeah this is actually easier than fedora imo

                scottalanmillerS black3dynamiteB 2 Replies Last reply Reply Quote 0
                • wrx7mW
                  wrx7m @black3dynamite
                  last edited by

                  @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                  Thank you for the how-to.
                  I am too spoiled on how to configure auto updates for Fedora and CentOS.

                  I just did this for Fedora 29 and am going to do it on my CentOS 7 server when I get a minute.

                  scottalanmillerS 1 Reply Last reply Reply Quote 0
                  • black3dynamiteB
                    black3dynamite @wrx7m
                    last edited by

                    @wrx7m said in How to configure automatic updates on Ubuntu 18.04 LTS:

                    @IRJ Yay! Someone else that uses Nano.

                    I use nano, vim, and vi.

                    IRJI 1 Reply Last reply Reply Quote 0
                    • IRJI
                      IRJ @black3dynamite
                      last edited by IRJ

                      @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                      @wrx7m said in How to configure automatic updates on Ubuntu 18.04 LTS:

                      @IRJ Yay! Someone else that uses Nano.

                      I use nano, vim, and vi.

                      One of my buddies has a christian looking sticker on his car that says

                      :w saves
                      
                      1 Reply Last reply Reply Quote 0
                      • scottalanmillerS
                        scottalanmiller @IRJ
                        last edited by

                        @IRJ said in How to configure automatic updates on Ubuntu 18.04 LTS:

                        yeah this is actually easier than fedora imo

                        Um, no. Fedora is like "install, set to "on" and done." SO easy.

                        IRJI 1 Reply Last reply Reply Quote 1
                        • scottalanmillerS
                          scottalanmiller @wrx7m
                          last edited by

                          @wrx7m said in How to configure automatic updates on Ubuntu 18.04 LTS:

                          @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                          Thank you for the how-to.
                          I am too spoiled on how to configure auto updates for Fedora and CentOS.

                          I just did this for Fedora 29 and am going to do it on my CentOS 7 server when I get a minute.

                          Our entire fleet has it and it took less time than it would take to do this once on Ubuntu 😉

                          IRJI 1 Reply Last reply Reply Quote 0
                          • IRJI
                            IRJ @scottalanmiller
                            last edited by

                            @scottalanmiller said in How to configure automatic updates on Ubuntu 18.04 LTS:

                            @IRJ said in How to configure automatic updates on Ubuntu 18.04 LTS:

                            yeah this is actually easier than fedora imo

                            Um, no. Fedora is like "install, set to "on" and done." SO easy.

                            Maybe you save a few seconds? :man_shrugging_light_skin_tone:

                            https://mangolassi.it/topic/15665/using-dnf-automatic-to-keep-fedora-up-to-date

                            1 Reply Last reply Reply Quote 0
                            • IRJI
                              IRJ @scottalanmiller
                              last edited by

                              @scottalanmiller said in How to configure automatic updates on Ubuntu 18.04 LTS:

                              @wrx7m said in How to configure automatic updates on Ubuntu 18.04 LTS:

                              @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                              Thank you for the how-to.
                              I am too spoiled on how to configure auto updates for Fedora and CentOS.

                              I just did this for Fedora 29 and am going to do it on my CentOS 7 server when I get a minute.

                              Our entire fleet has it and it took less time than it would take to do this once on Ubuntu 😉

                              How is that so?

                              unattended-upgrades should already be installed. I didnt have to install it on my stuff.

                              Other than you are literally copying to config files?

                              1 Reply Last reply Reply Quote 0
                              • black3dynamiteB
                                black3dynamite @IRJ
                                last edited by black3dynamite

                                @IRJ said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                Thank you for the how-to.
                                I am too spoiled on how to configure auto updates for Fedora and CentOS.

                                yeah this is actually easier than fedora imo

                                I don't know about that. I've done so many setups now that I script it.

                                # Install dnf-automatic
                                sudo dnf -y install dnf-automatic
                                
                                [email protected]
                                [email protected]
                                EMAILHOST=smtp.domain.com
                                sudo sed -i "s|^email_to = root|email_to = ${EMAILTO}|" /etc/dnf/automatic.conf
                                sudo sed -i 's|^apply_updates = no|apply_updates = yes|' /etc/dnf/automatic.conf
                                sudo sed -i 's|^emit_via = stdio|emit_via = email|' /etc/dnf/automatic.conf
                                sudo sed -i "s|^email_from = [email protected]|email_from = ${EMAILFROM}|" /etc/dnf/automatic.conf
                                sudo sed -i "s|^email_host = localhost|email_host = ${EMAILHOST}|" /etc/dnf/automatic.conf
                                egrep '^email_to|^apply_updates|^emit_via|^email_from|^email_host' /etc/dnf/automatic.conf
                                # Enable and Start dnf-automatic.timer
                                sudo systemctl enable --now dnf-automatic.timer
                                

                                Edit: Missing the setting for the email_host

                                IRJI wrx7mW 3 Replies Last reply Reply Quote 2
                                • IRJI
                                  IRJ @black3dynamite
                                  last edited by

                                  @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                  @IRJ said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                  @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                  Thank you for the how-to.
                                  I am too spoiled on how to configure auto updates for Fedora and CentOS.

                                  yeah this is actually easier than fedora imo

                                  I don't know about that. I've done so many setups now that I script it.

                                  # Install dnf-automatic
                                  sudo dnf -y install dnf-automatic
                                  
                                  [email protected]
                                  [email protected]
                                  EMAILHOST=smtp.domain.com
                                  sudo sed -i "s|^email_to = root|email_to = ${EMAILTO}|" /etc/dnf/automatic.conf
                                  sudo sed -i 's|^apply_updates = no|apply_updates = yes|' /etc/dnf/automatic.conf
                                  sudo sed -i 's|^emit_via = stdio|emit_via = email|' /etc/dnf/automatic.conf
                                  sudo sed -i "s|^email_from = [email protected]|email_from = ${EMAILFROM}|" /etc/dnf/automatic.conf
                                  # Enable and Start dnf-automatic.timer
                                  sudo systemctl enable --now dnf-automatic.timer
                                  

                                  It's the same if any difference at all. Although unattended-upgrades should already be installed, so there's that 😛

                                  black3dynamiteB 1 Reply Last reply Reply Quote 0
                                  • wrx7mW
                                    wrx7m @black3dynamite
                                    last edited by

                                    @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                    @IRJ said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                    @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                    Thank you for the how-to.
                                    I am too spoiled on how to configure auto updates for Fedora and CentOS.

                                    yeah this is actually easier than fedora imo

                                    I don't know about that. I've done so many setups now that I script it.

                                    # Install dnf-automatic
                                    sudo dnf -y install dnf-automatic
                                    
                                    [email protected]
                                    [email protected]
                                    EMAILHOST=smtp.domain.com
                                    sudo sed -i "s|^email_to = root|email_to = ${EMAILTO}|" /etc/dnf/automatic.conf
                                    sudo sed -i 's|^apply_updates = no|apply_updates = yes|' /etc/dnf/automatic.conf
                                    sudo sed -i 's|^emit_via = stdio|emit_via = email|' /etc/dnf/automatic.conf
                                    sudo sed -i "s|^email_from = [email protected]|email_from = ${EMAILFROM}|" /etc/dnf/automatic.conf
                                    # Enable and Start dnf-automatic.timer
                                    sudo systemctl enable --now dnf-automatic.timer
                                    

                                    stealing this 🙂

                                    1 Reply Last reply Reply Quote 1
                                    • black3dynamiteB
                                      black3dynamite @IRJ
                                      last edited by

                                      @IRJ said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                      @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                      @IRJ said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                      @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                      Thank you for the how-to.
                                      I am too spoiled on how to configure auto updates for Fedora and CentOS.

                                      yeah this is actually easier than fedora imo

                                      I don't know about that. I've done so many setups now that I script it.

                                      # Install dnf-automatic
                                      sudo dnf -y install dnf-automatic
                                      
                                      [email protected]
                                      [email protected]
                                      EMAILHOST=smtp.domain.com
                                      sudo sed -i "s|^email_to = root|email_to = ${EMAILTO}|" /etc/dnf/automatic.conf
                                      sudo sed -i 's|^apply_updates = no|apply_updates = yes|' /etc/dnf/automatic.conf
                                      sudo sed -i 's|^emit_via = stdio|emit_via = email|' /etc/dnf/automatic.conf
                                      sudo sed -i "s|^email_from = [email protected]|email_from = ${EMAILFROM}|" /etc/dnf/automatic.conf
                                      # Enable and Start dnf-automatic.timer
                                      sudo systemctl enable --now dnf-automatic.timer
                                      

                                      It's the same if any difference at all. Although unattended-upgrades should already be installed, so there's that 😛

                                      Maybe its Debian that doesn't have it included.

                                      1 Reply Last reply Reply Quote 0
                                      • IRJI
                                        IRJ
                                        last edited by IRJ

                                        Scripted a bit for anyone interested

                                        
                                        #***********************************************************
                                        # Install postfix and Unattended Upgrades
                                        #***********************************************************
                                        
                                        apt install -y unattended-upgrades
                                        apt install -y postfix
                                        
                                        #***********************************************************
                                        # Edit Config file
                                        #***********************************************************
                                        
                                        sed -i '/Unattended-Upgrade::Skip-Updates-On-Metered-Connections "true"/a\\Unattended-Upgrade::Mail "[email protected]";
                                        ' /etc/apt/apt.conf.d/50unattended-upgrades
                                        
                                        sed -i '/Unattended-Upgrade::Skip-Updates-On-Metered-Connections "true"/a\\Unattended-Upgrade::Remove-Unused-Dependencies "true";' /etc/apt/apt.conf.d/50unattended-upgrades
                                        
                                        sed -i '/Unattended-Upgrade::Skip-Updates-On-Metered-Connections "true"/a\\        "${distro_id}:${distro_codename}-updates";
                                        ' /etc/apt/apt.conf.d/50unattended-upgrades
                                        
                                        
                                        #***********************************************************
                                        # Create additonal config file
                                        #***********************************************************
                                        
                                        cat > /tmp/20auto-upgrades <<\EOF
                                        APT::Periodic::Update-Package-Lists "1";
                                        APT::Periodic::Download-Upgradeable-Packages "1";
                                        APT::Periodic::AutocleanInterval "7";
                                        APT::Periodic::Unattended-Upgrade "1";
                                        EOF
                                        
                                        #***********************************************************
                                        # Copy Config file
                                        #***********************************************************
                                        
                                        
                                        cp /tmp/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades
                                        rm /tmp/20auto-upgrades
                                        
                                        #***********************************************************
                                        # Enable and run Unattended-Upgrades
                                        #***********************************************************
                                        
                                        systemctl enable unattended-upgrades
                                        apt update
                                        unattended-upgrades
                                        
                                        DanpD 1 Reply Last reply Reply Quote 0
                                        • IRJI
                                          IRJ @black3dynamite
                                          last edited by

                                          @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                          @IRJ said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                          @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                          Thank you for the how-to.
                                          I am too spoiled on how to configure auto updates for Fedora and CentOS.

                                          yeah this is actually easier than fedora imo

                                          I don't know about that. I've done so many setups now that I script it.

                                          # Install dnf-automatic
                                          sudo dnf -y install dnf-automatic
                                          
                                          [email protected]
                                          [email protected]
                                          EMAILHOST=smtp.domain.com
                                          sudo sed -i "s|^email_to = root|email_to = ${EMAILTO}|" /etc/dnf/automatic.conf
                                          sudo sed -i 's|^apply_updates = no|apply_updates = yes|' /etc/dnf/automatic.conf
                                          sudo sed -i 's|^emit_via = stdio|emit_via = email|' /etc/dnf/automatic.conf
                                          sudo sed -i "s|^email_from = [email protected]|email_from = ${EMAILFROM}|" /etc/dnf/automatic.conf
                                          # Enable and Start dnf-automatic.timer
                                          sudo systemctl enable --now dnf-automatic.timer
                                          

                                          Are you installing postfix as well?

                                          black3dynamiteB 1 Reply Last reply Reply Quote 0
                                          • black3dynamiteB
                                            black3dynamite @IRJ
                                            last edited by

                                            @IRJ said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                            @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                            @IRJ said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                            @black3dynamite said in How to configure automatic updates on Ubuntu 18.04 LTS:

                                            Thank you for the how-to.
                                            I am too spoiled on how to configure auto updates for Fedora and CentOS.

                                            yeah this is actually easier than fedora imo

                                            I don't know about that. I've done so many setups now that I script it.

                                            # Install dnf-automatic
                                            sudo dnf -y install dnf-automatic
                                            
                                            [email protected]
                                            [email protected]
                                            EMAILHOST=smtp.domain.com
                                            sudo sed -i "s|^email_to = root|email_to = ${EMAILTO}|" /etc/dnf/automatic.conf
                                            sudo sed -i 's|^apply_updates = no|apply_updates = yes|' /etc/dnf/automatic.conf
                                            sudo sed -i 's|^emit_via = stdio|emit_via = email|' /etc/dnf/automatic.conf
                                            sudo sed -i "s|^email_from = [email protected]|email_from = ${EMAILFROM}|" /etc/dnf/automatic.conf
                                            # Enable and Start dnf-automatic.timer
                                            sudo systemctl enable --now dnf-automatic.timer
                                            

                                            Are you installing postfix as well?

                                            No, but I do have a postfix relay server setup for that purpose.

                                            IRJI 1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post