How to list installed packages on Ubuntu

s2 0

In this tutorial, we are going to show you how to list and filter installed packages on Ubuntu. Knowing how installed packages are listed on your Ubuntu system can be helpful in situations where you need to install the same packages on another computer or want to reinstall your system.

We’ll also show you how to check if a specific package is installed, count installed packages, and find out the version of an installed package.

Although this tutorial was written for Ubuntu, the same instructions apply to any Ubuntu-based distribution, including Kubuntu, Linux Mint, and Elementary OS.

List installed packages with apt

apt

is a command line interface for the package management system. It was introduced in Ubuntu 14.04 and combines the most commonly used commands apt-get and apt-cache including an option to list installed packages.

To list the installed packages on your Ubuntu system, use the following command:

sudo apt list --installed

As you can see from the output above, the command prints a list of all installed packages, including information about the package versions and architecture.

The package list is long and it is a good idea to forward the issue to less to make reading easier:

sudo apt list --installed | less

To find out if a particular package is installed, you can filter the output with the grep command. For example, to find out if the screen package is installed on our system, let’s do the following:

sudo apt list --installed | grep screen
screen/bionic,now 4.6.2-1 amd64 [installed]

The output above shows that screen version 4.6.2-1 is installed on our system.

List installed packages with dpkg-query

If you’re using an older version of Ubuntu, you can use the dpkg-query Command to list the packages:

sudo dpkg-query -l | less

The command shows you a list of all installed packages including package versions, architecture and a brief description.

You can filter dpkg-query -l Output with grep the same as that apt Exit:

sudo dpkg-query -l | grep package_name

Make a list of all installed packages

Here’s how to make a list of the names of all the installed packages on your Ubuntu or Debian system and save them in a file called packages_list.txt, run the following command:

sudo dpkg-query -f '${binary:Package}n' -W > packages_list.txt

Now that you have the list, you can install the same packages on your new server with:

sudo xargs -a packages_list.txt apt install

Count the number of packages installed on your Ubuntu computer

To find out how many packages are installed on your system you can use the same command as before, but instead of redirecting the output to a file, you can send it to the wc Utility and count the lines:

sudo dpkg-query -f '${binary:Package}n' -W | wc -l
544

As you can see, I have 544 packages installed on my Ubuntu server.

Conclusion

By now you should know how to list and filter installed packages on your Ubuntu system. If you want to know more about the. want to experience apt
Command open your terminal and type man apt.

Feel free to leave a comment if you have any questions.