There are several ways to list installed packages in Linux, and the method you use depends on the package management system used by your distribution. Here are the most common methods for popular distributions:
1. Debian/Ubuntu (apt/dpkg):
These distributions use the apt (Advanced Package Tool) and dpkg (Debian Package Manager) systems.
- Using Apt list:
This is a relatively new and user-friendly command to list installed packages:
Apt list —installed
This command lists all installed packages with their versions. You can also filter the list:
Apt list —installed | grep "keyword"
Replace "keyword" with the text you want to search for (e. g., a package name or part of a package name).
- Using Dpkg — l:
This command lists all packages known to the dpkg database, including those installed, uninstalled, or in a configuration state:
Dpkg -l
The output is a long list with information about each package. The first column indicates the package status:
- ii: Installed rc: Removed, but configuration files remain un: Uninstalled
To filter the list to show only installed packages, you can use grep:
Dpkg -l | grep "^ii"
To further filter by a keyword, combine grep commands:
Dpkg -l | grep "^ii" | grep "keyword"
- Using Aptitude (if installed):
Aptitude is an alternative package manager with a more interactive interface. If you have it installed, you can use it to list installed packages:
Aptitude search ~i
This command searches for all packages with the status ~i (installed). You can also filter the results:
Aptitude search ~i"keyword"
2. CentOS/RHEL/Fedora (yum/dnf):
These distributions use yum (Yellowdog Updater, Modified) or dnf (Dandified Yum) for package management. dnf is the modern successor to yum and is used by default in newer versions of Fedora and RHEL.
- Using Yum list installed:
This command lists all installed packages:
Yum list installed
You can filter the list by a keyword:
Yum list installed | grep "keyword"
- Using Dnf list installed:
This is the equivalent command using dnf:
Dnf list installed
And filtering:
Dnf list installed | grep "keyword"
- Using Rpm — qa:
This is a lower-level command that lists all installed RPM packages (the underlying package format used by yum and dnf):
Rpm -qa
You can filter the output:
Rpm -qa | grep "keyword"
3. Arch Linux (pacman):
Arch Linux uses pacman for package management.
- Using Pacman — Q:
This command lists all installed packages:
Pacman -Q
To filter the output:
Pacman — Q | grep "keyword"
- Using Pacman — Qq (quiet output):
This command lists only the package names, without version numbers or other information:
Pacman -Qq
This is useful for piping the output to other commands.
4. openSUSE (zypper):
OpenSUSE uses zypper for package management.
- Using Zypper se — i:
This command lists all installed packages. The -i option filters the results to show only installed packages. se stands for “search”.
Zypper se — i
To filter the output, use grep:
Zypper se — i | grep "keyword"
- Using Rpm — qa (also works on openSUSE):
As with CentOS/RHEL/Fedora, you can also use rpm — qa to list installed RPM packages.
5. Alpine Linux (apk):
Alpine Linux uses apk for package management.
- Using Apk info:
This command lists installed packages.
Apk info
To filter the output, pipe it to grep:
Apk info | grep "keyword"
Key Considerations:
- Package Manager: The command you use depends on the package manager used by your Linux distribution. Filtering: Using grep is a common way to filter the output of these commands to find specific packages. Case Sensitivity: grep is case-sensitive by default. Use the -i option to make it case-insensitive (e. g., grep — i "keyword"). Listing Only Package Names: Some commands (like pacman — Qq) provide an option to list only the package names, which can be useful for scripting. GUI Package Managers: Most distributions also have graphical package managers (e. g., Synaptic, GNOME Software, KDE Discover) that provide a visual interface for browsing and managing installed packages.
Choosing the Right Command:
- For Debian/Ubuntu, apt list —installed is the easiest and most user-friendly option. dpkg — l | grep "^ii" is also a reliable option. For CentOS/RHEL/Fedora, dnf list installed (or yum list installed if you’re on an older system) is the best choice. For Arch Linux, pacman — Q is the standard command. For openSUSE, zypper se — i is the recommended command. For Alpine Linux, apk info is the standard command.
Remember to use the appropriate command for your distribution’s package management system to accurately list installed packages.