How to Enable Automatic Updates and Security Updates in Ubuntu
hey everyone this is tony teaches tech i’m tony and i’m going to show you how to install updates automatically on ubuntu and this includes security updates so if that’s something you want to learn how to do let’s go ahead and hop on into the tutorial all right we’re going to be working with my website at micro domain so i’m going to log into that server via ssh it’s an ubuntu server i’ll put my password here and as you can see when we log in there are 26 ups updates that can be installed immediately 12 of these are security updates so normally without automatic updates obviously i would have to log into the server on a.

Thing We Want to Do Is Do A
frequent basis check for updates install those updates and make sure everything is good to go but the goal here is to make this happen automatically and the there’s infrastructure that we can put in place to actually have this happen and part of that is the unattended upgrades package and the other part of that is um a notifying piece to that aspect so let’s go ahead and uh install those packages so we have what we need and then we can configure them so the first thing we want to do is do a sudo apt install unattended upgrades and i’ll type in the password here and then that’s already on the system so we can do sudo.
apt install update notifier common and that is update notifier c-o-m-m-o-n-n-o-t-i-f i-e-r there we go all right so we already we also have that on our system as well um now with those uh those installs we get to uh we there’s what i should say is part of those installs are some configuration files that we have to edit so let’s edit them i’m going to use the vim text editor here it’s under etc apt apt.conf dot d and then 50 unattended upgrades now in here is basically as it says at the top automatically upgrade packages from these pairs so basically by default it’s selecting only the security updates if you wanted to install all updates unattended.
you can do that by getting rid of these two slash marks here i’m just going to do the security updates because um another decision that we’ll have to make is do you want to reboot the server because a lot of times when you install an update you might have to reboot the server and if that’s the case um and you have a live production website then maybe that’s not the best thing you want to do or uh and we’ll get into this too you can configure that to happen at a low um volume of users like middle of the night kind of thing so you can pick what you want to update here and we’ll.

You Don’t Want to Be Updated Like Your
or i should say upgrade here let’s move down here if there is a package that you know you don’t want to be updated like your your web server because you it might break something or like your mysql database you can use the syntax down here to blacklist those type of applications in packages we’re not going to do any of that but we’ll keep working our way down this file and the part that i actually want to look for is um uh yeah so unattended upgrade mail right here so in order to be notified via email that an upgrade was a security update in this case happened you can type in your email address so let’s.
do tony at tony teaches.tech and then you can pick what type of updates you want do you want to be notified when via email when an error occurred or do you want to be notified anytime that a system was updated anything like that you can do only on only one dash air on change i’m going to do only on error because that’s really all i wanted to know about otherwise everything’s working the way it should be what else do we have down here do you also want to remove unused kernel packages yes i think i do want that do you want to remove new unused dependencies yes and do you want to remove unused dependencies.
now i i can’t remember off the top of my head what the difference is between these two new unused dependencies and unused dependencies but it doesn’t hurt to have them both uncommented here as i was alluding to earlier unintended upgrades for do you want the system to reboot automatically and depending on your production system if it is a production system this could work out with true because down here we can specify a time that we want that update to happen so although the updates are installed at a an earlier time in the day perhaps potentially um the only time that will reboot is for example in the middle of the night at 2 a.m when.

I Just Want You Guys to Know That
it’s not going to have a high impact to your to your website so you don’t have to do what i’m doing but i just want you guys to know that this is available um there’s some other options here that’s all the major ones that i want to discuss with you though so let’s go ahead and save our configuration changes now and um just because we made those configuration changes we still haven’t i guess enabled the unintended upgrades at this point so in order to do that i’m going to copy this and paste it here so we want to do a d package reconfigure dash p plow dash plow is actually a priority low and then.
unattended upgrade so let’s go ahead and execute that and you can read through this but it’s basically saying this is important to do to install these updates do you want this to happen do you automatically want to download and install stable updates yes and now it’s creating that configuration file for us at this location so let’s go ahead and look at that so we can do sudo vim this and basically in this this is already configured for you but it’s saying uh unattended upgrades is true it’s either one or zero in this case and do we want to update our packages as well like it this is equivalent to pseudo app update right here and.
sudo apt upgrade right here okay so those are fine right now and you know if if you wanted to at this point you can do something like this and i’m not going to do it because it kind of takes a little bit of time to do sudo unattended upgrades dry run and debug just to see what kind of would happen but like i said i’m not going to do that to waste time on what i do think is valuable is the fact that while you can configure when these updates are installed it takes a little bit more work um i want you to know that the default and i should explain this the default is.

Execute the Updates the We’re Going to Check
going to execute at lib systemd system apt-daily.timer so if you look at that file basically every day it’s gonna at six am in six pm and some random offset from that within 12 hours we’re going to execute the updates the we’re going to check for updates and if there are updates we’re going to install them so that’s kind of confusing what do i mean so basically twice a day between 6am and 6 p.m some random time in there and between 6 pm and 6 a.m some random time in between there we’re gonna check for updates so that’s basically what this syntax means right here at this point you’re good to go you can log out.
get out of your session and uh the next time you log in within the next i guess 12 to 24 hours like we saw in the beginning of this tutorial that there were 26 updates that can be installed the next time you come in you’ll see that that has happened and actually if you do want to look at the logs here you can look at the history at var log apt history log in i’m not sure if that’ll exist now no it doesn’t exist so um but that’ll start to populate with information even after you do the debug um which i just showed you the dry run here that’ll populate the history.log so hopefully that.

Out I Want to Thank You
all makes sense um if you have any questions let me know in the comments below i’ll do my best to help you out i want to thank you guys for watching for more like this from me in the future and if you do i’ll see you in the next one [Music] you.

