Nội dung
In this article, I will show the difference between an apt update vs an apt upgrade on Ubuntu OS.
I. Introduction
The apt update
and apt upgrade
commands are two of the most commonly used commands on Ubuntu but are misunderstood by many Linux users. For some, they play the same role, which is not true in all cases. In this guide, AZDIGI will show you to distinguish between the two and how to use each.
II. Difference between apt update vs apt upgrade
1. The command apt update
This command is mainly called after installing a new system or before installing a new software package.
The apt update
command only updates the Linux system’s package indexes or the package list. Therefore, this command will not upgrade any packages on the system at all, unlike many Linux users mistakenly believe.
A package index file is a database file that contains a list of software packages defined in software repositories. And this file is in the path /etc/apt/sources.list
. And to see this list, you just need to use the following command to view:
cat /etc/apt/sources.list
The list of other packages will be located in the /etc/apt/sources.list.d
directory.
The apt update
command is extremely safe to run. You can run this command again if you accidentally aborted or your Ubuntu server simply shut down unexpectedly.
For Ubuntu 18.04
and later releases, we use the following command:
sudo apt update Hoặc lệnh sau khi chạy đang với user root: apt update
For Ubuntu 16.04
and below, we use the following command:
sudo apt-get update Hoặc lệnh sau khi chạy đang với user root: apt-get update
2. The command apt upgrade
When you upgrade your package to the latest version, you will need to use an apt upgrade
command. This command will not ask you to have any options behind it.
In case you want to know the list of packages on your Ubuntu server that are out of date and need to be updated, you need to run the following command:
sudo apt list --upgradable Hoặc lệnh sau khi chạy đang với user root: apt list --upgradable
Here is a list of outdated packages on my Ubuntu server:
Upgradable packages will be listed with the following information:
passwd/focal-updates 1:4.8.1-1ubuntu5.20.04.1 amd64 [upgradable from: 1:4.8.1-1ubuntu5.20.04]
Note:
- Package name with the update: passwd.
- Latest version: 1:4.8.1-1ubuntu5.20.04.1
- OS Architecture: amd64
- The version being installed (outdated): 1:4.8.1-1ubuntu5.20.04
After we get the list of updates, let’s upgrade the packages and update the security patches with the following command. But to be on the safe side, you should have a system backup before executing this command:
sudo apt upgrade -y
Then you wait a moment for the process of updating the packets to complete.
Note: Until the update packages are finished, you absolutely must not turn off the Ubuntu server, shutting down the server during this process may cause system errors.
III. Summary
The command apt update
is used to synchronize the package list on your system. It fetches the latest package list for PPAs and repositories on your system and ensures that they are up to date.
The command apt upgrade
will upgrade packages to their latest versions and install new support packages if required. This command will not remove any packages; if any packages are marked for removal, it will ignore them.
Upgrading the packages on the Ubuntu server in particular and other server operating systems in general will help our system work more stable, have better compatibility and fix some bugs found in earlier versions.
See more useful articles about Ubuntu at the following link:
If you need assistance, you can contact support in the ways below:
- Hotline 247: 028 888 24768 (Ext 0)
- Ticket/Email: You use the email to register for the service and send it directly to support@azdigi.com.