apt Command in Linux: Examples for Ubuntu/Debian 2024

Looking for a quick and easy way to manage deb packages on Ubuntu, Debian, or other Linux distributions? Look no further than apt! This powerful command-line utility lets you install, update, and remove packages with ease, thanks to its user-friendly interface and customizable options.

Unlike other tools like apt-get and apt-cache, which are better suited for scripting and automation, apt is specifically designed for interactive use. With its intuitive commands and flexible options, it’s the perfect tool for anyone who wants to manage their Linux packages quickly and easily.

Of course, it’s important to remember that most apt commands require sudo privileges, so be sure to run them as a privileged user. And if you’re looking for a handy reference guide to all the different apt commands, you’ve come to the right place – this guide has everything you need to get started!

apt Command in Linux

Updating package index (apt update)

Essentially, the APT package index functions as a database that stores information about the packages that are accessible from the enabled repositories on your system.

To refresh the package index and obtain the most recent updates from the APT repositories, execute the following command:

sudo apt update

It is recommended to update the package index prior to installing new packages or upgrading existing ones.

Upgrading packages (apt upgrade)

Keeping your Linux system up to date is crucial for maintaining its overall security.

To update the currently installed packages to their latest versions, execute the following command:

sudo apt upgrade

Upgrading packages that require the removal of installed packages is not supported by the command.

To upgrade a specific package, you can provide its name as a parameter:

sudo apt upgrade package_name

Configuring automatic security updates is a prudent decision to make.

Full Upgrading (apt full-upgrade)

In contrast to an upgrade, a full-upgrade may involve the removal of installed packages in order to upgrade the entire system.

sudo apt full-upgrade

Exercise additional caution while utilizing this command.

Installing packages (apt install)

Executing the subsequent command makes the installation of packages effortless:

sudo apt install package_name

To install multiple packages simultaneously using a single command, list them with space as a separator:

sudo apt install package1 package2

In order to install local deb files, you must specify the complete file path. Otherwise, the command will attempt to obtain and install the package from the APT repositories.

sudo apt install /full/path/file.deb

Removing Packages (apt remove)

To uninstall a package that has been installed, use the following command:

sudo apt remove package_name

To uninstall several packages, you can list them separated by spaces as follows:

sudo apt remove package1 package2

However, note that the remove command may not eliminate all configuration files. If you wish to completely remove the package along with its configuration files, use the purge command instead:

sudo apt purge package_name

Remove Unused Packages (apt autoremove)

If you install a new package that has dependencies, the dependencies will also be installed. However, when you uninstall the package, the dependencies are not automatically removed and may be left unused on the system. To clean up these leftover packages, you can use the command:

sudo apt autoremove

Listing Packages (apt list)

The command list enables you to view the packages that are available, installed, and can be upgraded. To display all the available packages, use the following command:

sudo apt list

By executing the command, you will be able to view a comprehensive inventory of packages, featuring details such as package versions and architecture. If you wish to determine whether a particular package has been installed, you may utilize the grep command to refine the output.

sudo apt list | grep package_name

Type the following command to display a list of installed packages:

sudo apt list --installed

It can be helpful to obtain a list of packages that can be upgraded prior to proceeding with the upgrade process:

sudo apt list --upgradeable

Searching Packages (apt search)

To find a specific package from the list of available packages, you can use the following command:

sudo apt search package_name

Upon successful search, the command will display all the packages whose names match the provided search term.

Package Information (apt show)

Prior to installing or removing a package, it could be helpful to have access to details such as package dependencies, installation size, and package source.

You can use the show command to obtain information regarding a specific package.

sudo apt show package_name


In summary, mastering package management is a crucial aspect of Linux system administration. When it comes to Debian-based distributions, apt is the go-to package manager. If you’re looking to expand your knowledge of apt commands, simply open your terminal and type man apt.

As always, if you have any questions, feel free to drop them in the comments below. Keep honing your Linux administration skills and stay ahead of the game!



Hey there! My name is Alex and I'm a professional content writer. I'm also lucky enough to be part of an amazing trio team! I absolutely love what I do and I'm passionate about creating content that engages, informs, and entertains. Whether it's writing blog posts, website copy, or social media content, I always strive to deliver high-quality work that exceeds expectations.

We will be happy to hear your thoughts

Leave a reply