How to manage packages in Ubuntu?

Ubuntu has an extensive package management system that includes installation, setup, upgrade, and package deletion. The package management features include software update checking and resolving dependencies. It also enables you to access a well-organized repository of 60,000 software packages for your Ubuntu system.

Most Ubuntu users prefer graphical application managers when they first start using Ubuntu. Although the graphical application manager of Ubuntu has a large number of applications, it still lacks many powerful utilities, particularly those for the command line. After realizing this, move forward to using “apt-get,” a more competent package management tool.

What is apt in Ubuntu

For the dpkg packaging system, “apt” is a command-line frontend. “apt” stands for “Advanced Packaging Tool”. For many distributions, it is the most favored method of managing packages via the command line. A Linux-based operating system like Ubuntu has this primary package management system. This utility can be used to:

  • Update installed software
  • Update package repositories
  • Get the source code for any installed package
  • Search for available packages
  • Remove a package from your Ubuntu
  • Reinstall a software package.

While the program”dpkg” forms the essential packaging layer in Ubuntu, “apt-cache” and “apt-get” implement dependency handling and offer user-friendly interfaces. With the help of “apt-get“, you can install, update, upgrade, and uninstall packages, while “apt-cache” is utilized for searching and retrieving information related to packages from the packages database.

What is the difference between apt-get and apt?

apt-get is a command-line “backend” that provides supports for other apt-based tools and apt is intended for the end-users. apt utility comprises the features of apt-cache and apt-get. apt commands replace the commonly used apt-cache, apt-get, and their features, still, most of them are not all backward compatible, also apt-get is the default package manager in Ubuntu. That’s the reason why in this article, we are pursuing the usage of apt-get (default package manager) in our Ubuntu system. In the upcoming section, we will talk about how to manage packages in Ubuntu. So, let’s get started!

How to update packages in Ubuntu

The apt-get works with a database of known and accessible software applications. It uses this database to perform installations, searching packages, and a variety of other tasks. So, before we begin any apt-get packaging activities, we must first check that our local copy of the database is updated. Utilize the below-given command to update the repositories. For most activities, apt-get needs administrator privileges:

$ sudo apt-get update

How to upgrade packages in Ubuntu

If you want to upgrade the packages, then write out the below-given command in your Ubuntu terminal:

$ sudo apt-get upgrade

Enter “Y/y” to permit the process to continue:

You can also utilize the “dist-upgrade” option for a more comprehensive upgrade and to ensure dependencies are resolved:

$ sudo apt-get dist-upgrade

Now, let’s move towards the installation of packages on our system.

How to install a new package in Ubuntu

You can use below-given syntax to install a package if you know its name:

$ sudo apt-get install [PackageName]

For instance, we will install the “flameshot” package in our Ubuntu which is a freely available annotation tool for Ubuntu users. This package has a wide range of markup tools. To install it on our system, we will write out this command:

$ sudo apt-get install flameshot

That was the procedure for installing a single package.

How to install multiple packages in Ubuntu

In Ubuntu, multiple packages can be installed simultaneously, which is excellent for getting all the software needed for a project in one go. Here is the syntax for installing multiple packages using apt-get:

$ sudo apt-get install [FirstPackageName] [SecondPackageName] ...

In the below-given example, we will try to install two packages, “fping” and “vim” using a single command:

$ sudo apt-get install fping vim

Enter “y” to permit the operation to install multiple packages:

How to remove a package in Ubuntu

check out the syntax of the apt-get command, if you want to delete or remove a package from your Ubuntu:

$ sudo apt-get remove [PackageName]

For instance, we will remove the installed “flameshot” package by utilizing the below-given command:

$ sudo apt-get remove flameshot

The execution of the above-given command will keep the configuration files while removing the package on Ubuntu. Your settings will be saved in this way, although the application has been removed from your system. If this isn’t what you want, then clean all of the configuration files:

$ sudo apt-get autoremove

Write out the following command to remove packages that are no longer requires:

$ sudo apt-get purge [PackageName]

We will perform this operation for the “vim” package:

$ sudo apt-get purge vim

How to search for a package in Ubuntu

The “apt-cache” is utilized in the terminal for searching for a package that meets your requirement and it does not require any administrative privileges. Here is the syntax of the “apt-cache” command:

$ apt-cache search [PackageName]

Now, we will execute the “apt-cache” command to search for the “htop” package:

$ apt-cache search htop

Instead of searching for a specific package, you can also look for packages using some generic terms. For example, we will look for the packages utilized for “mp3 conversion”:

$ apt-cache search mp3 convert

How to view package information in Ubuntu

Utilize the below-given command if you want to view information related to a specific package:

$ apt-cache show [PackageName]

As an example, execute this command for viewing the information of “htop” package in the Ubuntu terminal:

$ apt-cache show htop

If you utilize the “policy” option the “apt-cache” command, it will show you the packages dependencies and the download size of the searched package:

$ apt-cache policy htop

Execution of the above-given will also let you know if the package is installed in your system and to which repository it belongs:


Knowing how to manage and use multiple packages in Ubuntu can assist the user in the daily tasks. Installing and downloading packages from repositories, handling dependencies, and updating and removing packages operations are essential for Linux system administration. You learned about how to manage packages in Ubuntu in this article. If you are spending your time and effort in Ubuntu, read out our article to better understand managing packages in Ubuntu.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.