If you want to know what software packages are installed on your Ubuntu system, you can use various commands and tools to list them. This article will show you how to list all installed packages in Ubuntu using apt, dpkg, and other methods. You will also learn how to filter the output, save it to a file, and count the number of installed packages.
Table of Contents
- Why List Installed Packages in Ubuntu?
- How to List Installed Packages in Ubuntu with apt
- How to List Installed Packages in Ubuntu with dpkg
- How to List Installed Packages in Ubuntu with Other Methods
- How to Save the List of Installed Packages in Ubuntu to a File
- How to Count the Number of Installed Packages in Ubuntu
- Conclusion
Why List Installed Packages in Ubuntu?
There are several reasons why you might want to list the installed packages on your Ubuntu system. Some of them are:
- To review the packages and remove the ones that are no longer needed or wanted.
- To install the same packages on another Ubuntu system or a fresh installation.
- To troubleshoot issues related to package dependencies or conflicts.
- To audit the security and stability of your system by checking for outdated or vulnerable packages.
How to List Installed Packages in Ubuntu with apt
apt is a command-line interface for the package management system in Ubuntu. It was introduced in Ubuntu 14.04 and combines the most commonly used commands from apt-get and apt-cache.
To list the installed packages on your Ubuntu system with apt, use the following command:
sudo apt list --installed
The command will print a list of all installed packages, including their versions and architectures. The output will look something like this:
accountsservice/bionic,now 0.6.45-1ubuntu1 amd64 [installed]
acl/bionic,now 2.2.52-3build1 amd64 [installed]
acpi-support/bionic,now 0.142 amd64 [installed]
acpid/bionic,now 1:2.0.28-1ubuntu1 amd64 [installed]
adduser/bionic,now 3.116ubuntu1 all [installed]
...
The output may be very long, depending on how many packages you have installed. To make it easier to read, you can pipe the output to less, which will allow you to scroll through it:
sudo apt list --installed | less
You can also filter the output with grep, which will search for a specific package name or a keyword. For example, to find out if the screen package is installed, you can run:
sudo apt list --installed | grep screen
The output will show only the matching line:
screen/bionic,now 4.6.2-1 amd64 [installed]
How to List Installed Packages in Ubuntu with dpkg
dpkg is a low-level tool that manages Debian packages. It can be used to install, remove, configure, and list packages.
To list the installed packages on your Ubuntu system with dpkg, use the following command:
sudo dpkg -l
The command will show a table of all installed packages, including their versions, architectures, and descriptions. The output will look something like this:
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii accountsservic 0.6.45-1ubun amd64 query and manipulate user account
ii acl 2.2.52-3buil amd64 Access control list utilities
ii acpi-support 0.142 amd64 scripts for handling many ACPI ev
ii acpid 1:2.0.28-1ub amd64 Advanced Configuration and Power
ii adduser 3.116ubuntu1 all add and remove users and groups
...
The first column shows the desired action, the second column shows the current status, and the third column shows whether there is an error. The most common values are:
- ii: The package is installed and configured.
- rc: The package is removed but its configuration files remain.
- un: The package is not installed.
You can filter the output with grep, as explained in the previous section. For example, to find out if the screen package is installed, you can run:
sudo dpkg -l | grep screen
The output will show only the matching line:
ii screen 4.6.2-1 amd64 terminal multiplexer with VT100/A
How to List Installed Packages in Ubuntu with Other Methods
There are other methods to list the installed packages on your Ubuntu system, such as using graphical tools or online services. Some of them are:
- Synaptic Package Manager: A graphical tool that allows you to manage packages in a user-friendly way. You can install it with
sudo apt install synaptic
and launch it from the menu or the command line. To list the installed packages, go to the Status section and select Installed. - Ubuntu Software Center: A graphical tool that allows you to browse and install software from the official Ubuntu repositories and third-party sources. You can launch it from the menu or the command line. To list the installed packages, go to the Installed tab.
- Aptik: A graphical tool that allows you to backup and restore your system settings, including the installed packages. You can install it with
sudo apt-add-repository -y ppa:teejee2008/ppa && sudo apt update && sudo apt install aptik
and launch it from the menu or the command line. To list the installed packages, go to the Packages section and select Installed Packages. - Ubuntu Packages Search: An online service that allows you to search for packages in the Ubuntu repositories. To list the installed packages, enter
installed
in the Keyword field and select your Ubuntu version and architecture.
How to Save the List of Installed Packages in Ubuntu to a File
You may want to save the list of installed packages on your Ubuntu system to a file, for example, to keep a record of them, to share them with someone else, or to install them on another system.
To save the list of installed packages to a file, you can redirect the output of any of the commands mentioned above to a file. For example, to save the list of installed packages with apt to a file named packages.txt in your home directory, you can run:
sudo apt list --installed > ~/packages.txt
The file will contain the same output as the command, but without the colors and formatting. You can open it with any text editor or view it with cat:
cat ~/packages.txt
To save the list of installed packages with dpkg to a file named packages.txt in your home directory, you can run:
sudo dpkg -l > ~/packages.txt
The file will contain the same output as the command, but without the colors and formatting. You can open it with any text editor or view it with cat:
cat ~/packages.txt
How to Count the Number of Installed Packages in Ubuntu
You may want to count the number of installed packages on your Ubuntu system, for example, to compare it with another system, to monitor the growth of your system, or to satisfy your curiosity.
To count the number of installed packages on your Ubuntu system, you can use the wc command, which counts the number of lines, words, and characters in a file or a stream. For example, to count the number of installed packages with apt, you can pipe the output of the command to wc and use the -l option to count only the lines:
sudo apt list --installed | wc -l
The output will show only the number of lines, which corresponds to the number of installed packages. For example:
544
This means that there are 544 packages installed on the system.
To count the number of installed packages with dpkg, you can pipe the output of the command to wc and use the -l option to count only the lines:
sudo dpkg -l | wc -l
The output will show only the number of lines, which corresponds to the number of installed packages. For example:
544
This means that there are 544 packages installed on the system.
Conclusion
In this article, you learned how to list all installed packages in Ubuntu using various methods, such as apt, dpkg, Synaptic, and others. You also learned how to filter the output, save it to a file, and count the number of installed packages.
You can use these methods to manage your packages, troubleshoot issues, backup and restore your system, and more.
If you have any questions or feedback, feel free to leave a comment below.