How to keep your Ubuntu Server updated with patches and security fixes, using the command line

In Ubuntu you can install all your updates through the command line. You will often have to do this if you are running Ubuntu server without a GUI. Lets take a look at some of the commands to help keep you secure and up to date with all the open-source goodness.

Ubuntu is often petty good at letting you know that updates are available when you login to your machine.

 

 

Updates Available - Notice When I SSH into my Server

 

 

sudo apt-get update

This will refresh the list of all available updates. I would recommend running this before you run the upgrade commands to make sure you are getting all the available updates.

 

 

sudo apt-get update

 

 

Enter Your Password

 

 

Enter Your password

 

 

Progress (Will vary on the repositories you have enabled)

 

Refresh of package list progress

 

 

sudo apt-get upgrade

This will install almost all updates except some of the big things like kernel updates and things that may require you to restart the system after the change. This will work a large amount of the time. If you however get something similar to "The following packages have been kept back: landscape-common linux-generic-pae linux-headers-generic-pae linux-image-generic-pae" you will need to run the dis-upgrade command and it will require a restart to have the changes applied.

 

 

sudo apt-get upgrade

 

Kernel and header updates held back

 

 

sudo apt-get dist-upgrade

This command will allow you to apply a kernel upgrade or some big changes that will require a restart to take effect. If this is a production survey I would recommend running this off peak hours.

 

 

sudo apt-get dist-upgrade

 

Enter Y to continue and install ubuntu updates

 

 

Simple enough! These three commands can help keep your Ubuntu or Debian based system up to-date and secure.

 

Hope you found this helpful!