In this blog post, we will look at how to check installed packages on Ubuntu and Debian-based systems. This includes how to generate a list of all the installed packages, checking for a specific package, getting a count of the number of installed packages, and creating a text file of the installed packages. From there a bonus section with even more related like how to get more information about a specific package, where apt and dpkg log to, and even how to list packages installed using newer packager managers like Snap and Flatpak.
What Is A Package Management System?
The concept of package managers has been around for quite some time, but to summarize the original concept was to centralize software distribution methods. The concept is to have one place to install, upgrade, configure, and remove software packages.
Introduction
Linux systems have different options in package management systems like RPM. Ubuntu and Debian-based systems generally use .deb files as their primary method of package management. On these systems, apt or dpkg are going to be the likely frontends you will find for interacting with these packages.
List Installed Packages
To list the installed packages using apt package manager use the command below (be warned there will be quite a few)
apt list --installed
If you’re on a system that doesn’t have apt try this dpkg command instead.
sudo dpkg -l
List A Specific Package
If you’re looking to confirm if a specific package is installed you can add the package name to the command as shown below.
apt list --installed [package]
The same goes for dpkg.
dpkg -l pattern
Getting A Count Of The Installed Packages
This command will count the number of times installed is listed to provide a count of the number of installed packages.
apt list --installed | grep -c installed
This will do the same for the dpkg output
dpkg -l | grep -c '^ii'
Bonus
Creating A List Of Installed Packages
It’s possible to create a list that can then be restored on another system to install the same packages.
To create the file use the below command.
dpkg -l | grep '^ii' | awk '{print $2}' > installed_packages.txt
To restore the packages use the following command.
xargs -a installed_packages.txt sudo apt-get install -y
Need More Information About A Package?
If you’re looking for more details about a package try running the apt show command with the package name appended to it as shown below.
apt show [package]
The result will look like the following example ran on the bash command.
Logs
If you are looking for logs as to when a package was installed I would recommend starting by reviewing the logs listed below.
- /var/log/dpkg.log
- /var/log/apt/history.log
Other Package Managers You Might Find
In recent years there have been several new packages come into existence trying to solve issues like compatibility, security, and other modern concerns. The two of those you are most likely to see are called Snap and Flatpak and the commands to list installed packages are listed below.
Snap
Snap is a software packaging and deployment system developed by Canonical. To list installed packages via snap run the following command.
snap list
If you get a message that the command is not found that means snap isn’t installed.
Flatpak
Flatpak is simmular to snaps, although it should be noted there are many differences in the technologies. To see if there are any installed packages via flatpak run the following command.
flatpak list
If you get a message that the command is not found that means snap flatpak installed.
Conclusion
Although we only covered listing installed packages on Ubuntu and Debian-based systems we started by touching on what a packager manager is, moving on ways to list traditionally installed packages. From there the bonus section has a variety of information, from creating a list of installed packages and getting more information about a specific package, to where installation logs can be found, and how to list packages in other packager managers you might find.
Additional Links
Looking for information on Package management why not check these out?
Embracing a lifelong passion for technology since childhood, CJ delved into the intricate workings of systems, captivated by the desire to understand the unknown. This innate curiosity led to his discovery of Linux, a revelation that resonated deeply. With more than 7 years of on the job experience, he’s honed his technical skills as a Geek and Senior Linux Systems Administrator.
Leave a Reply