Like many other Linux distributions, Ubuntu relies on applications to help users accomplish their tasks. These applications come in two formats – preinstalled software bundled with the default Ubuntu installation and additional packages you can install using a package manager such as apt or dpkg.
You can use these package managers to view installed packages and display relevant information in the terminal. The specifics of the process differ depending on the package manager used for the installation.
In this tutorial, you will learn how to use apt and dpkg to view information about installed packages. We will discuss 10 scenarios where you can use the package manager on your Ubuntu system to get information about the installed packages.
Working With Package Managers on Ubuntu 22.04
Let’s dive into the scenarios where you can use the available package manager on your system to get package information.
The Prerequisites
Before trying out the following ideas, make sure you have the following:
- A system running Ubuntu (or any Debian-based Linux distribution).
- A user account with root or sudo privileges
Note that from Ubuntu 14.04 onwards, apt is the standard package manager for handling software packages.
Use Case #1: Display All Installed and Accessible Packages
Run the following command to list all installed and available packages on your Ubuntu system:
# apt list
This command can generate an extensive list detailing the packages, including version and architecture. To make this list more manageable, we recommend the less command:
# apt list | less
Now, you can navigate through this list using the Up or Down arrow keys or Spacebar to advance a page. Press q to exit.
Use Case #2: Display Exclusively Installed Packages
Use this command to view only the installed packages:
#apt list --installed
The –installed flag filters the list to show only the installed packages. You will notice that the entries are tagged as follows:
- [installed] denotes manually installed packages.
- [installed, automatic] signifies packages installed automatically as dependencies.
- [installed, local] shows packages not sourced from the official repositories.
Use Case #3: List Down Specific Packages
You can list down information about the specific packages on your Ubuntu system. For instance, you can run the following command to directly specify the package name with the apt list command:
#apt list <package name> --installed
You can exclude the –installed flag to see details regardless of the package’s installation status.
The apt list command can generate a long list of information. We recommend filtering this long list with grep to search for a package by name:
#apt list --installed | grep -i <package name>
The -i option ignores case sensitivity, broadening the search scope.
Use Case #4: Retrieve Package Details Using apt show
Run the following command syntax to get comprehensive details about the package, including its installation status:
#apt show <package name>
Use Case #5: Identify Upgradable Packages
We recommend the –upgradable option to list only the packages that can be upgraded. This is a very useful option that you can use to find the packages that are updated in the official repositories.
The command syntax in this case is as follows:
#apt list --upgradable
Use Case #6: Count the Installed Packages
Run the following command to count the total installed packages:
#apt -qq list --installed | wc -l
The -qq option minimizes the output to a mere count.
Use Case #7: Identify Packages Using dpkg
In earlier Ubuntu versions, where apt may not be present, you would use dpkg, another popular package manager. Run the following command to list installed packages via dpkg:
#dpkg --get-selections | grep -w "install"
You can also combine dpkg-query with grep to list all installed packages:
#dpkg-query -l | grep ii
Use Case #8: Save the Installed Package Names
You can save the names of all installed packages into a file by running the following dpkg command that saves the list to a text file named packages_list:
#dpkg --get-selections | grep -w "install" | cut -f1 > packages_list.txt
Note that the cut command isolates and saves the package names into a text file.
Use Case #9: Count the Installed Packages with dpkg
You can run the following command to determine the number of installed packages by counting the lines in the output of dpkg:
#dpkg --get-selections | grep -w "install" | wc -l
Use Case #10: Sort Installed Packages by Installation Date
You often need to view the installation date and time of packages to determine if the system has outdated packages. You can find this information in the dpkg logs (often located at /var/log/dpkg.log):
Use Case #11: List the Installed Snap Packages
Snap, another popular package manager, is also present on Ubuntu systems. You can run the following command to list its packages:
# snap list
Conclusion
Understanding how to list and manage installed packages on Ubuntu is essential for effective system administration. We mentioned 10+ use cases where we demonstrated the use of apt, dpkg, and snap to list down and manage installed packages.
If you’re looking for a robust server for your Linux projects, we offer the best dedicated server pricing and deliver instant dedicated servers, usually on the same day the order gets approved. Whether you need a dedicated server, a traffic-friendly 10Gbps dedicated server, or a powerful bare metal server, we are your trusted hosting partner.
FAQs
Q. How can I list installed packages on Ubuntu 22.04 using APT?
To list the installed packages on Ubuntu 22.04 using APT, you can use the following command: apt list –installed.
Q. What is the command to check for installed packages on my Ubuntu system?
You can check for installed packages on your Ubuntu system by using the following command: dpkg –get-selections.
Q. How do I count the number of installed packages on my Ubuntu system?
To count the number of installed packages on your Ubuntu system, you can use the following command: dpkg –get-selections | wc -l.
Q. Can I list all installed packages, including dependencies on Ubuntu 22.04?
Yes, you can list all installed packages, including dependencies, on Ubuntu 22.04 by running the command: apt list –installed.
Q. Is there a way to show only the specific package that is installed on my Ubuntu system?
Yes, you can show only a specific package that is installed on your Ubuntu system by using the command: dpkg -l | grep [package_name].
Q. How do I learn how to list installed applications on Ubuntu 22.04 using APT?
To learn how to list installed applications on Ubuntu 22.04 using APT, you can refer to the official Ubuntu documentation or use the command: apt list –installed.
Q. What is Ubuntu’s package management system for handling installed packages?
Ubuntu utilizes apt (Advanced Package Tool) as its package management system to handle the installation, removal, and management of software packages on the system.
Q.What is a package list on Debian-based distributions?
It’s a record of all available or installed software packages on the system, viewable via commands like dpkg -l or apt list –installed.
Q. How is the dpkg command used?
dpkg manages software packages, allowing you to install (dpkg -i), remove (dpkg -r), and list (dpkg -l) packages on Debian-based systems.
Q.What is Synaptic Package Manager?
Synaptic is a graphical interface for managing software packages (installing, updating, or removing) on Debian-based systems.
Q. What does apt update do?
It refreshes the package list, ensuring the system knows about the latest available packages and versions.
Q. Why might multiple package versions be in the cache?
To allow installation of different versions for compatibility or specific requirements, but careful management is needed to prevent conflicts.