If you are like me you like to use the terminal commands to update your Linux Ubuntu System. Its fast and easy if you know the command. I am putting the command lines in this article so you can copy and paste them. First login as root then navigate to your root folder.  

sudo su  //logs you in as root
cd / //navigates you to the root folder

Update Linux

If you use the following commands you will only have to enter your root password once. Then the above step is not necessary. :-)

sudo apt update        // Fetches the list of available updates
sudo apt upgrade -y       // Strictly upgrades the current packages
sudo apt install --fix-missing    //fixes anything missing that it can fix
sudo apt-get dist-upgrade  //Installs updates (new ones)
sudo apt clean //Cleans up and speeds up your system

Enter the lines above in order and you will have an updated machine.

UPDATING YOUR LINUX UBUNTU SYSTEM UPDATING YOUR LINUX UBUNTU SYSTEM

Here are some more useful commands.

sudo apt full-upgrade -y //Full upgrade (includes removing or replacing packages if necessary):


sudo apt autoremove --purge -y //Clean up unused packages and dependencies:


The command sudo apt-get dist-upgrade is similar to sudo apt full-upgrade. It upgrades packages but also handles changes in dependencies, such as installing new packages or removing obsolete ones. This makes it slightly more advanced than sudo apt upgrade, which avoids removing or replacing packages.

When to Use sudo apt-get dist-upgrade

  • Use it when you want to ensure all packages and their dependencies are updated, even if some obsolete packages need to be removed or replaced.
  • It's particularly useful for upgrading to a new kernel or resolving complex dependency changes.


Differences Between upgrade and dist-upgrade

  • sudo apt upgrade: Updates all upgradable packages without removing or replacing any existing packages.
  • sudo apt-get dist-upgrade: Updates all packages while allowing removal of packages and installation of new ones to resolve dependencies.

The -y option automatically answers "yes" to prompts, making it useful for automation.

Update the Kernel

Check the current kernel version:

uname -r

Install updates for the kernel: (This is part of full-upgrade, but you can explicitly update the kernel if needed.)

sudo apt install --install-recommends linux-generic

Reboot the server to apply the new kernel:

sudo reboot

Optional: Upgrade to the Latest Distribution Version

Check if a new version is available:

sudo do-release-upgrade -c

Upgrade to the new release:

sudo do-release-upgrade

Other Useful Update Commands

Show held-back packages (packages that weren't upgraded):

sudo apt-mark showhold

Fix broken dependencies:

sudo apt --fix-broken install

Reconfigure packages if needed:

sudo dpkg --configure -a

Optional: Install Third-Party Updates (if applicable)

sudo snap refresh

Update Flatpak packages:

flatpak update -y

Update software from PPAs (if you've added any):

sudo apt update && sudo apt upgrade -y

Automate Updates

Install unattended-upgrades (for automatic updates):

sudo apt install unattended-upgrades -y

Enable unattended upgrades:

sudo dpkg-reconfigure --priority=low unattended-upgrades

After Updates

sudo reboot

Verify the update status:

lsb_release -a

Check if the system is up-to-date:

sudo apt update && sudo apt upgrade -y

These commands will ensure your server is up-to-date, secure, and running the latest stable software versions.



Sign Up To Comment