apt-get upgrade and upgrade both commands are used in Debian-based Linux distros to update the software packages. Undoubtedly, the apt-get package management tool is great to use to perform package installation, update, removal, and so on. Therefore, to update the package information, you can use apt-get update. On the other hand, to upgrade an installed package to its latest version, run the apt-get upgrade in your Ubuntu terminal. Though both commands perform updates, their purposes are different. So to know the differences between apt-get update Vs apt-get upgrade, stick to this article.
Key Takeaways
- Knowing about apt-get package manager.
- Learning the uses of apt-get update.
- Knowing the uses of apt-get upgrade.
- Learning the differences between apt-get update vs upgrade.
Requirements
- Must be a root user to avail of sudo privileges.
What Does Apt-get Update Do?
In the Linux system, all the information of the packages is stored in ‘/etc/apt/sources.list’ files. The apt-get update basically downloads the latest information of the packages from the source file. Thus, it updates the package index files with all necessary information along with package versions. It is recommended to run this update command before upgrading any package as it ensures that you have all the updated information available to be upgraded to the newest version.
What Does Apt-get Upgrade Do?
The apt-get upgrade automatically downloads the latest version of the packages and replaces the old version package by installing the new one. It actually updates the installed packages in your Linux system. When you wish to have some extra and modern features in your software package, upgrading the package can fulfill your desire. This command ensures that you have the latest versions of the packages that keep your system up-to-date and healthy.
Apt-get Update Vs Apt-get Upgrade
The apt-get update downloads the index files whereas the apt-get upgrade downloads the latest versions packages of the installed packages.
You can update a piece of package information with the apt-get update command. On the other hand, the apt-get upgrade command is used to install a new version package.
Downloading the most recent information from the sources.list file is the main task of the apt-get update command. However, the main task of an apt-get upgrade command is not downloading the package data but downloading the actual recent package version installed in your system.
You can run the apt-get update command when you only want to update the package details. Crontastly, use the apt-get upgrade command if you want to have a modern version software package.
How to Use the ‘apt-get Update’ Command
Using the apt-get update command is an effortless task. Some basic steps are needed to perform this command. Don’t forget to run this command without the sudo prefix as it requires administrative permissions. Now, follow the steps mentioned below to use it properly:
Steps to Follow >
➊ Open the Ubuntu terminal.
➋ Update the packages with the apt-get package manager by writing the following code:
sudo apt-get update
Now you have all the recent information about the packages.
How to Use the ‘apt-get Upgrade’ Command
To use this apt-get upgrade command, you just need to access the Ubuntu terminal and run the code with sudo to have administrative privileges. Check the steps below:
Steps to Follow >
➊ Open the Ubuntu terminal.
➋ Now, upgrade all the installed packages with the apt-get upgrade command:
sudo apt-get upgrade
- upgrade: Upgrades packages to the latest versions in Linux.
After you enter your Ubuntu password, the updating procedure will begin. Next, press ENTER. Now, type ‘y’ to finish the updating process. All of the packages on your Linux system are currently installed in their latest versions.
How to Use Special Options With the ‘sudo apt-get upgrade’ Command
There are multiple operations that can be done with the sudo apt-get update command. They are as follows:
Command options | Description |
---|---|
-y or –yes | Automatically answers yes to all prompts. |
-s or –simulate or –dry-run | Simulates the upgrade process without making any changes. |
–only-upgrade | Upgrades only existing packages. |
-u or –show-upgraded | Shows an upgraded package list. |
-V or –verbose-versions | Displays version information in detail. |
In this table, you can see different options that can be used with the apt-get upgrade command. However, -y and –dry-run commands are the most used commands. Let’s know more about it.
How to Use the ‘–yes’ or ‘-y’ Option With apt-get upgrade Command
This command answers yes to any prompts asking your permission. Check the steps to get the benefits of it:
Steps to Follow >
➊ Open your Ubuntu terminal.
➋ Write the code to check the result:
sudo apt-get upgrade -y
- -y: Answers yes to all prompts.
You can notice in this picture that it has no prompt to ask your permission to proceed.
How to Use the ‘–dry-run’ or ‘-s’ Option
With the use of this command-line option, you can mimic an upgrade without executing any. It is safer to explore an upgrade before applying it because you will be able to see what would occur with an upgraded package. Check the detailed steps:
Steps to Follow >
➊ Open your Ubuntu terminal.
➋ Write the code to check the result:
sudo apt-get upgrade -s
- -s: Simulates the upgrade process without making system changes.
You can see what will happen if you do an upgrade in your terminal by looking at this image. It doesn’t alter the system; just demonstrates the process to you.
Apt or Apt-get? Which One Should You Be Using?
apt stands for Advanced Packaging tool which offers a modern interface for managing packages in Linux whereas apt-get is an outdated and low-level package management system. apt provides additional advantages that apt-get doesn’t do. Apt-get requires a command option to upgrade packages but apt can handle packages automatically. Hence, apt is more convenient to use than apt-get.
Some Examples of Apt and Apt-get
In this section, I will show you two Practical examples of using apt and apt-get package managers. First, you will get to know how the installation procedure works with these commands. Then, the removal process. Let’s get into the detail.
Example 01: Installing a Package With Apt and Apt-get
A package dependency contains all the necessary functions to operate the package successfully. Sometimes many unwanted dependencies can be downloaded with the software package during installation. To handle them, package managers are needed. Check the working procedure of the two package managers below to handle dependencies:
Steps to Follow >
➊ Open the Ubuntu terminal.
➋ Run this command to install a package with apt.
sudo apt install vlc
- install: Installs packages in Linux.
- vlc: Package name.
Here, the vlc package is installed without any dependency issues.
➌ Now, install the same vlc package with apt-get:
sudo apt-get install vlc
Dependency problems may arise in this installation procedure. However, to fix that, follow the next command.
➍ To fix the broken dependency, run this command:
sudo apt-get -f install vlc
- -f: Fixes broken dependencies during package installation.
No dependency issues will occur after running this command.
Example 02: Removing a Package With Apt and Apt-get
During package removal with apt, it automatically removes the unused dependency along with the package but to do the same task, apt-get needs two separate commands. See the procedure in detail:
Steps to Follow >
➊ Open the Ubuntu terminal.
➋ To remove vlc package with unused dependencies, run this command:
sudo apt remove vlc
- remove: Removes packages with unnecessary dependencies.
Here, the vlc package along with its unused dependencies has been removed.
➌ However, apt-get removes only the package but not the dependencies. Write the following code to remove the vlc package:
sudo apt-get remove vlc
After removing, it suggests running autoremove command to remove the unnecessary dependencies.
➍ To remove the unnecessary dependencies with apt-get, run this command:
sudo apt-get autoremove
- autoremove: Removes unused dependencies of the packages in Linux.
All the unused dependencies of vlc have been removed now.
Comparative Analysis of Apt-get Update and Apt-get Upgrade
Here, I have explained the advantages and disadvantages of the two commands.
Commands | Pros | Cons |
---|---|---|
apt-get update |
|
|
apt-get upgrade |
|
|
Both commands are useful to update packages. Before upgrading any package update must be run to ensure the most recent data of the packages. Therefore, perform both if you want to upgrade any package otherwise perform only the apt-get update command.
Conclusion
In this article, I have gone through two different package managers including apt and apt-get. I have explained how to use update and upgrade arguments with apt-get. Moreover, different important options of the apt-get upgrade command are discussed elaborately. After reading the whole content, you will be able to know the basic differences between apt-get update and upgrade and can find out which one is better on your own. Good luck!
People Also Ask
Related Articles
- dnf Update Vs Upgrade [Which One Is Better]
- Yum Update Vs Upgrade [Basic Differences]
- How to Use ‘sudo apt full-upgrade’ in Linux [A complete Guide]
<< Go Back to Upgrade Package in Linux | Package Management in Linux | Learn Linux Basics