How to update Ubuntu from terminal

How to update Ubuntu from terminal

It's almost time for a new version of Ubuntu to be released. When the time comes, you have to consider whether you are going to stay in the current version or go up to the new one. The decision is more difficult if we are using an LTS version, since we have the option of staying in something that is supposed to be more stable, but when we are in a normal cycle, what we have to decide is when to jump, or what otherwise we will be left without support. Whether for one reason or another, or at any time, here we are going to teach you how to update ubuntu from terminal.

When a user searches the Internet for how to update Ubuntu from the terminal, they can do it for two reasons, or to update two different things: one is to update the packages; the other is to update the operating system. To make sure this article works for everyone, here we are going to explain both, starting with the packages, something that, it must be said, I think is "first Ubuntu user".

How to update Ubuntu from terminal: starting with the packages

Not everything has always been so smooth in Linux. when i started using it there were no software stores, and the closest thing to that was Synaptic (archive article), a way to manage packages from a user interface. But they taught me the fastest way, one that I still use today on the computers that I have Ubuntu. The command they taught me was this:

sudo apt update && sudo apt upgrade && sudo apt autoremove

Given the command, it is necessary to explain what it does what:

  • sudo is the command required to gain privileges.
  • apt is the package manager that Ubuntu uses.
  • Update will update the repositories.
  • upgrade will update the packages.
  • self-remove will remove packages that are no longer needed. EYE with this, that it is not always a good idea to do it. I do it out of habit, but it cannot be ruled out that a package that is needed by other software will be removed. It has never happened to me that I missed something after using it, but I leave the warning there.
  • && is the "logical and", and means "and", but as long as the above has been executed successfully. In this compound command, "sudo apt autoremove" will only be executed if "sudo apt upgrade" has been executed successfully, and "sudo apt upgrade" will only be executed if "sudo apt update" has been executed without errors. This, translated into human language, would be “update the information in the repositories; if they update successfully, update the packages; if they update successfully, remove any packages that are no longer needed."

What we would see when executing the first and second command is what is in the header capture, a list with all the packages that are going to be updated. If we want to see the list in a clearer way, we can cancel (n and Enter) and type in the terminal:

sudo apt list --upgradable

With this we will have all the packages updated, and everything necessary would already be explained if the question of how to update Ubuntu from the terminal refers only to the packages.

Upgrade the entire operating system

If what the answer to the question of how to update Ubuntu from terminal is operating system level, we continue. After updating all the packages, and although it may not be necessary, I recommend restarting the computer. If we want to do everything with the terminal, what we have to write is:

sudo reboot

Once restarted, the next thing to do It depends on whether we are in an LTS version or in a normal cycle version. As in the normal cycle the same is done as in the LTS but at a more advanced point, we explain all the steps, that is, we are going to assume that we are in an LTS and we want to upgrade to a non-LTS.

What we have to do is tell the operating system to look for new versions of the normal cycle operating system, but before we also write this command:

sudo apt dist-upgrade

If we see that you have updated many packages, I would reboot again, or add this command to the above list and reboot when the whole process is finished. If few have been updated, I think we can continue with the steps of the update itself.

  1. Now we open the terminal and write:
sudo nano /etc/Update-manager/release-upgrades
  1. We scroll to where it says "prompt=lts" and change it to "prompt=normal".

Upgrade to normal cycle releases

  1. We press Ctrl+O, then Enter and then Ctrl+X. To make sure that the changes have been made, we can press the up arrow on the keyboard and re-enter the command from the previous step. After confirming that it is ok, we exit with Ctrl+X.
  2. This is where it is also valid for non-LTS versions. In the terminal we write sudo do-release-upgrade. If there is a new version, a rather long message will appear. We scroll up, see the numbering and name of the new version and press the S (for Yes, or Y if it is in English) and then Enter. You can press S and Enter directly if you don't want to see any of the information that the terminal shows you.

sudo do-release-upgrade

  1. Next we will see that it starts working, updating repositories and others. We wait.
  2. We will see something similar to the above again. If we do not want to know anything else or stop the installation, press the S and then Enter. With D we will see the details of the installation (I do not recommend it; time is lost).

How to update Ubuntu from terminal, summary

  1. We will see again that it starts working in a similar way as when we update the packages from the terminal. We wait for the process to finish. It can take a while depending on your connection and what you have to install.

Updating the operating system

  1. After a while, the packages that are no longer necessary will be uninstalled. It is a very similar step to the previous one, but this time it will delete what is no longer necessary.

Uninstall unnecessary packages

  1. After having removed everything that is no longer necessary, we will see another “yes/no” window, but this time to restart. It is best to press the S key and then Enter.

Reboot after update

  1. Once restarted we will be in the new version of Ubuntu, but I would not leave it here. I would go back to the update packages section and do it again, so we will have the new system and all the updated packages.

About LTS to LTS upgrades

Everything explained here also applies to updating from one LTS version to another LTS, but one detail must be taken into account: Canonical does not usually activate updates from one LTS to another until at least one point update is released. For example, you didn't activate 22.04 updates until they released the 22.04.1 ISO. It usually takes three to six months, more three than six, but you have to know that updates cannot be done in April; you have to wait at least until august.

And with this, we hope that it has become clear how to update Ubuntu from terminal.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   octavio said

    Good morning, I want to update my Xubuntu 18.04 to one of the latest versions, for example 22.04, will it be possible to jump directly or do I have to update to previous versions first?