4

How to List Installed Packages in Ubuntu With APT

 3 years ago
source link: https://www.makeuseof.com/apt-list-installed-packages/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to List Installed Packages in Ubuntu With APT

By Deepesh Sharma

Published 18 hours ago

Here's how you can use Ubuntu's default package manager to get a list of packages currently installed on your system.

When you want to remove unwanted software from your system, having a list of all installed packages right in front of you can help. On Ubuntu, APT makes it easier for users to get a list of packages currently installed on their system.

In this guide, you will learn how to list installed packages on Ubuntu using APT, the default package manager on Debian-based distributions.

Get a List of Installed Packages on Ubuntu

To output a list of packages that are currently installed, are upgradeable, or available on Ubuntu, you can use the list method of the APT command. To only print packages installed on your system, specify the --installed flag with the command.

sudo apt list --installed

Output:

using apt list function ubuntu

The output generated by the aforementioned command contains additional information, including the version number and package state.

To get a clean output suitable for use in scripts and output transfer, you can use string manipulation tools like sed or awk. For example, to print only the package names:

sudo apt list --installed | awk '{split($0, a, "/"); print a[1]}'

Output:

clean output with awk ubuntu

Related: These sed Examples Will Make You a Linux Power User

You can also count the total number of packages. All you have to do is pipe the output of the aforementioned command with wc. Word count, abbreviated wc, is a Linux utility that counts the number of characters, words, or lines present in a text file.

sudo apt list --installed | wc -l

Output:

counting the number of installed packages ubuntu

As you can see in the output above, 2177 Linux packages are currently installed on the system.

Using dpkg-query

Users running older versions of Ubuntu can use the dpkg-query command to get a list of installed packages.

sudo dpkg-query -l

Dpkg will present the output in a clean, tabular format by default.

list installed packages using dpkg

To strip out additional information and print only the names of the packages, run the following command:

sudo dpkg-query -f '${binary:Package}\⁠n' -W

Output:

clean output using dpkg-query

Learn More: What Is the Difference Between APT and dpkg in Ubuntu?

Package Management Made Effortless With APT

In addition to the list method, APT has several other functions that provide information associated with Linux packages. It also takes away the headache of removing unnecessary dependencies by keeping records of installed and uninstalled packages on your system.

Like APT, several other package managers are available for Linux, including DNF, pacman, and YUM. Most Debian-based distros ship with APT, while Arch Linux and RHEL-based systems use pacman and DNF as their default package managers respectively.

About The Author

5fffefc47b152-SAVE_20210106_204702.jpg?fit=crop&w=100&h=100

Deepesh Sharma (80 Articles Published)

Deepesh is the Junior Editor for Linux at MUO. He writes informational guides on Linux, aiming to provide a blissful experience to all newcomers. Not sure about movies, but if you want to talk about technology, he's your guy. In his free time, you can find him reading books, listening to different music genres, or playing his guitar.

More From Deepesh Sharma

Subscribe to our newsletter

Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!

Click here to subscribe

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK