Page 1 of 1

How to Update your Server.

Posted: Sat Jan 20, 2018 3:57 pm
by Rob Swan
For me one of most important steps you need to take to keep your server running without interruption, is to turn off automatic updates.

I know most will say this is totally the wrong thing to do, but let me tell you a little story.

A while ago I went on a Holiday, my server was set for automatic updates.

I got a phone call from a friend to say that the server was down. I checked from my end and I could not get any response from my server remotely using any method.

A week later when I returned home, I checked my server to see what was going on.

To cut a long story short, due to chain reaction caused by a failed auto update the entire thing was beyond recovery (within a sensible time frame), so had to re-install the entire thing from scratch.

If automatic updates had been turned off this would not have happened, the only downside would be that I would have to update the system myself maybe once a week.

It your call, but I highly recommend you turn off automatic updates, so here is how it’s done.

Login to your server using your PC and PuTTY.

Enter this command.

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

Image

When the file opens files press I for insert and change this line.

APT::Periodic::Unattended-Upgrade "1";

To

APT::Periodic::Unattended-Upgrade "0";

We just changed the 1 to a 0.

Image

Some other websites may tell you to change this line instead

APT::Periodic::Update-Package-Lists "1";

This would work but then you will not be informed of available updates when you login using Putty.

Then save the changes and exit the editor (Press Escape, then :w (enter) then :q (enter) )

Re boot your server as normal with this command.

sudo shutdown -r now

Automatic updates have now been turned off.

If you did turn off automatic updates, this is how to update your server by hand.

It is probably a good idea to reed through THIS FAQ before continuing

Log into you server using your PC and Putty.

Image

If your server says there are no updates to do, then nothing to do just log out (type exit and then press enter)

If there are updates to be done, enter this command.

sudo apt-get update (press enter) (as always you may need to re-enter your password)

Image

Be patient and wait for it to finish…. (Wait for the prompt YOUR-USERNAME@Web-Server:~$ )

Image

Next run this command to actually install the updates.

sudo apt-get upgrade (press enter)

Image

Enter Y to continue when prompted to do so….

Again be patient and wait for it to finish…. (Wait for the prompt YOUR-USERNAME@Web-Server:~$ )

Image

Now re-boot your server using this command…..

sudo shutdown -r now (press enter)

Wait a few minutes to give your server chance to re-start.

Log back in using Putty (if you cannot log into your server, it probably has not yet fully re-started).

next, run this command.

sudo apt-get dist-upgrade

Follow the same procedure as above to install the additional updates and then reboot your server once again.

After running the second command, if they are still updates available follow the update procedure again.

Sometimes, during the update process you may notice that some updates have been kept back.

Image

Officially, you don’t need these updates right now, however I always install them anyway.

If you are like me and you want all available updates to be installed, first highlight the kept back ones with the mouse.

Image

Type in the command sudo apt-get upgrade then press space, finally right click on the cursor to paste in the kept back updates.

Image

Press enter.

Enter Y to continue when prompted to do so….

Image

When the there are no more update available, the system should tell us so when logging in.

Image

Once, all the updates have completed and the system has been rebooted, all that remains is just a quick clean up.

To perform a clean up, enter each of these command in turn (follow any on screen prompts).

sudo apt-get autoremove

sudo apt-get autoclean

sudo apt-get clean

This is something that you should do a least once a week to keep your system running smoothly. I tend to do this anytime the system tells me it needs doing.

Also once the system is actually live, I would suggest you take backups just in case the updates cause you any problems.

If you are done for today logout by typing exit (press enter)