List all installed packages on Debian

29/12/2020
Chưa phân loại
This tutorial will explain how to list installed packages on Debian, including all options to list the necessary packages. On LinuxHint was already explained how to uninstall packages in Debian, that article included a brief introduction to packages listing, now all options for listing packages will be explained using dpkg, dpkg-query and apt package managers.

dpkg/dpkg-query

Debian packages manager is dpkg, dpkg is the command we use to install, remove and manage Debian packages. To know how dpkg files are created you can check this article on the topic.

To do a simple full list of all packages installed in our Debian system run:

dpkg -l

As you see there are 4 columns displaying the program names, versions, architecture support and description.

A dpkg-query -l command will throw exactly the same output, two ways to get the same information on packages:

For a more comfortable view you can add the less parameter, run from the console:

dpkg-query -l | less

If we want to search for a specific .deb package and if it’s installed run:

dpkg -s <package> | grep Status

Try:

dpkg -s nano | grep Status

Then try with a package you know you don’t have, in my case ill use tomcat:

dpkg -s tomcat | grep Status

As you can see the first output says nano is installed, while the second says tomcat isn’t installed but available.

Now if we want to list the specific package with  the information provided with dpkg -l type:

dpkg -l <package>

Try:

dpkg -l nano

Again the dpkg-query equivalent will throw the same output

If you want to list all files belonging to a package type:

dpkg -L <filename>

Try

dpkg -L nano

This command lists all files belonging to nano and it’s paths. We can have this information before installing the package, get a .deb package and try:

dpkg -c <.deb>

In this case dpkg -c shows the directories and files which will get installed with Teamviewer.

Now let’s find out the total number of packages installed in our device, run:

dpkg-query -f ‘${binary:Package}n’ -W | wc -l

dpkg-query allow us to export a list of installed packages which we can use later to reinstall the same software on a different device. To create a list of installed packages run:

dpkg-query -f ‘${binary:Package}n’ -W > inststalledPackages

Now try:

less inststalledPackages

apt

Apt (Advanced Package Tool) is another packages manager available on Debian and Ubuntu based Linux distributions. Despite to find information on packages dpkg has advantages over apt, apt is better since it can resolve dependencies when installing software. But also apt can be useful to list packages and get information on them.

To get a list of installed packages with apt run:

apt list –installed

You can also add the less parameter to have a comfortable view, allowing to pass lines and pages easily.

apt list –installed | less

With apt we can also use grep to look for a specific package, on the console type:

apt list –installed | grep -i nano

You can ignore the warning, apt informs about the package’s presence.

If we want to list dependencies for a package with apt, type in the terminal:

apt-cache depends <program>


This output reveals Teamviewer’s dependencies.I hope you found this article on listing programs and their information on Debian and Ubuntu systems. As you see each program (dpkg, dpkg-query or apt) has it’s own advantages and disadvantages, while dpkg/dpkg-query allow us to gather more information apt can help where dpkg fails like dependencies.Keep following LinuxHint for more tips and updates on Linux.

Sandclock IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, Sandclock IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to install SteamOS on Ubuntu 17.04

This tutorial on how to install SteamOS on Ubuntu is for game enthusiast, and someone that loves playing games on Steam....
28/12/2020

Pandas read_csv Tutorial

Pandas .read_csv I have already discussed some of the history and uses for the Python library pandas.  pandas was designed...
28/12/2020

NextCloud – Giải pháp lưu trữ đám mây cho doanh nghiệp.

Nextcloud cung cấp đến doanh nghiệp của bạn nền tảng lưu trữ đám mây, lưu trữ một nơi xem,...
30/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Hướng dẫn chuyển đổi windows server windows evaluation to standard và active windows server 2008 + 2012 + 2016 + 2019
26/10/2021

How to Update Ubuntu Linux
24/10/2021

Squid Proxy Manager cài đặt và quản lý Proxy Squid tự động trên ubuntu
20/10/2021

Hướng dẫn cài đặt Apache CloudStack 4.15.2.0
19/10/2021

Hướng dẫn ký file PDF bằng chữ ký số (chữ ký điện tử) và sửa lỗi mới nhất 2021 foxit reader
19/10/2021