How to Check If a Package is Installed in Linux

Understanding and managing installed packages is essential for maintaining a secure and efficient Linux system.

Installed packages refer to the software applications and system components added to your Linux environment via package managers.

By regularly checking if a package is installed in Linux, you can ensure your system remains optimized and free from outdated or unnecessary software, aiding in both system auditing and troubleshooting.

​To list installed packages on various Linux distributions, you can use the following commands:​

  • Debian/Ubuntu: apt list --installed
  • Red Hat/CentOS/Fedora: rpm -qa​
  • Arch Linux: pacman -Q
  • OpenSUSE: zypper search -is
  • Fedora (modern systems): dnf list installed
  • Fedora (legacy systems): yum list installed
  • Snap Packages: snap list
  • Flatpak Packages: flatpak list​

Prerequisites to Check If a Package is Installed in Linux

To check installed packages Linux, ensure the following first:

  • Ensure you have administrative privileges, as some commands may require sudo.
  • Identify your Linux distribution’s package manager (APT, DNF, Pacman, etc.).
  • A Linux VPS running a compatible Linux distribution (Ubuntu, Debian, CentOS).
  • Run a package list update (sudo apt update, dnf check-update) for accurate results.
  • Use precise package names to avoid errors when checking for installed software.

How to Check Installed Packages by Package Manager

Using a package manager is the most efficient and reliable way to check installed packages in Linux, as it directly queries the system’s database to verify installed software and dependencies.

Package managers provide structured output, ensuring accuracy across different distributions while allowing seamless package management, updates, and removals.

Debian & Ubuntu-Based Systems (APT & DPKG)

Debian-based distributions, such as Ubuntu, Linux Mint, and Pop!_OS, use APT and DPKG for package management.

You can use the following commands to reliably check if a package is installed.

Using dpkg (low-level package manager)

The dpkg -l command lists all installed packages and their details:

dpkg -l | grep opera

Example Output:

ii  opera-stable  95.0.4635.37  amd64  Fast and secure web browser

The grep opera part filters the output to show if “opera” is installed. If no output appears, the package is not installed.

Using apt (higher-level package manager)

The apt list --installed gives a clearer view of installed packages:

apt list --installed | grep opera

Example Output:

opera/stable,now 95.0.4635.37 amd64 [installed]

If the package is installed, it will show up with details such as version and architecture.

RHEL, CentOS, Rocky Linux & Fedora (DNF, YUM, & RPM)

Red Hat-based distributions use DNF, YUM, and RPM as package managers. These tools allow you to check installed packages in Linux for specific packages.

Using dnf (modern systems)

The dnf list installed checks the installed packages and filters for your considered packages:

dnf list installed | grep opera

Example Output:

opera-95.0.4635.37-1.x86_64

If no output is returned, the package is not present.

Using yum (legacy systems)

The yum list installed command functions similarly to DNF, listing all installed packages and allowing you to check if package is installed in Linux:

yum list installed | grep opera

Example Output:

opera.x86_64 95.0.4635.37-1

Using rpm (direct package query)

The rpm -q command queries the RPM database for the specified package:

rpm -q opera

Example Output:

opera-95.0.4635.37-1.x86_64

If the package is installed, it shows the name and version.

Arch Linux & Manjaro (Pacman)

Arch-based distributions, including Manjaro, use Pacman for package management.

Using pacman

The pacman -Q checks the package database for the specific package:

pacman -Q opera

Example Output:

opera 95.0.4635.37-1

If the package is installed, it shows the name and version. If it’s missing, an error message will be displayed.

OpenSUSE (Zypper)

OpenSUSE uses Zypper to manage packages.

Using zypper

The zypper se --installed-only command filters the search results to show only installed packages, allowing you to easily check installed packages in Linux:

zypper se --installed-only opera

Example Output:

opera-stable  95.0.4635.37-1

Alpine Linux (APK)

Alpine Linux, known for its lightweight design, uses APK as its package manager. To Linux check if package is installed​​, you can use the following command:

Using apk

The apk info shows details of the installed package:

apk info opera

Example Output:

opera-95.0.4635.37-r0 description: Fast and secure web browser

If the package is not installed, it will produce no output, allowing you to check installed packages in Linux with ease.

Snap Packages

Snap is a universal package manager that works across various Linux distributions.

Using snap

The snap list command shows all installed Snap packages, and grep opera filters the results to show the specific package:

snap list | grep opera

Example Output:

opera    95.0.4635.37  123456  canonical  -

If the package is installed, it will display its version and other details.

Flatpak Packages

Flatpak is another universal package manager designed to run on any Linux distribution.

Using flatpak

The flatpak list command displays a list of installed Flatpak packages:

flatpak list | grep opera

Example Output:

opera 95.0.4635.37  stable  org.opera.Opera

Using grep filters for the specific package, showing version and other relevant details.

Checking Installed Packages in Linux Using Visual Methods

While command-line tools provide efficient ways to check installed packages in Linux, some users prefer graphical interfaces for a more intuitive experience.

Graphical Package Managers (GPMs) offer a user-friendly approach to see all installed packages and manage software installations.

Most Linux distributions come with a default graphical package manager that allows users to browse, install, and manage software packages visually.

These tools provide a comprehensive view of installed applications and available updates.

Ubuntu/Debian-Based Systems

  • GNOME Software Center:
  1. Open the GNOME Software application from your applications menu.
  2. Navigate to the “Installed” tab to view all installed packages.
  3. You can search for specific packages or browse through categories.

Checking Installed Packages Using Gnome

  • Synaptic Package Manager:

Install Synaptic if it’s not already installed, run:

sudo apt-get install synaptic
  1. Launch Synaptic from the applications menu.
  2. Use the “Status” filter to view installed packages.
  3. Synaptic allows you to mark packages for installation, removal, or upgrade with ease.

Checking Installed Packages Using Synaptic Package Manager

Red Hat/CentOS/Fedora-Based Systems

  • GNOME Software
  1. Open GNOME Software from your applications menu.
  2. Go to the “Installed” section to see all installed packages.
  3. Search and manage packages as needed.
  • DNFDragora
  1. Install DNFDragora if it’s not already installed using sudo dnf install dnfdragora
  2. Launch DNFDragora from the applications menu.
  3. It provides a graphical interface to manage packages using DNF.

Arch Linux-Based Systems

  • Pamac Package Manager
  1. Install Pamac if it’s not already installed, running sudo pacman -S pamac
  2. Open Pamac from your applications menu.
  3. Navigate to the “Installed” tab to view and manage packages.

OpenSUSE

  • Zypper GUI
  1. Install Zypper GUI if it’s not already installed, using sudo zypper install zypper-gui
  2. Launch Zypper GUI from the applications menu.
  3. It provides a graphical interface to manage packages using Zypper.

Methods to List and Manage Installed Packages in Linux

Mastering how to check installed packages in Linux is crucial for administrators, developers, and power users.

Whether for troubleshooting, optimizing systems, or migration, knowing how to check if a package is installed in Linux ensures smoother workflows and fewer complications.

This part covers advanced techniques to check installed packages in Linux, helping you manage your software environments with precision and efficiency.

Counting Installed Packages Across Linux Distributions

Knowing the number of installed packages on your system can give you valuable insights into system bloat, unnecessary dependencies, and potential optimization opportunities.

Counting installed packages allows you to assess the software footprint and overall system complexity.

Here are the methods for how to find installed packages in Linux across various distributions:

Debian and Ubuntu

You can count all installed packages on your system with:

apt list --installed | wc -l

This command lists all installed packages and uses wc -l to count them, offering a clear view of the system’s software load.

Red Hat-based systems (Fedora, CentOS, RHEL)

On RPM-based systems, run:

rpm -qa | wc -l

This provides the number of packages installed via the RPM package manager, helping you gauge the size of your software stack.

Arch-based systems (Manjaro, Arch Linux)

Use the following command on Arch-based distributions:

pacman -Q | wc -l

This command counts all packages installed via Pacman, allowing you to quickly evaluate system software.

Backing Up Installed Packages for Migration or Recovery

One of the best practices for how to check installed application in Linux is creating a backup of your package list. This is particularly useful when migrating to a new machine or recovering from a system failure.

By saving the list of installed packages, you can restore your environment seamlessly on another system.

Here’s how to backup installed packages on different distributions:

Debian and Ubuntu

Use the following command to back up your installed packages:

apt list --installed > installed_packages.txt

This command saves a comprehensive list of installed packages in a text file, making it easy to restore or migrate to another system.

Red Hat-based systems

For CentOS, Fedora, and RHEL, run:

rpm -qa > installed_packages.txt

This stores a list of installed RPM packages, providing a reliable backup for your system.

Arch-based systems

On Arch Linux or Manjaro, you can save the list of installed packages with:

pacman -Qqe > installed_packages.txt

This command captures explicitly installed packages and saves them to a file for later use.

Restoring Installed Packages from Backup

Once you’ve backed up your installed packages, restoring them to a fresh system or recovering from an issue becomes straightforward.

By reinstalling packages from a saved list, you ensure consistency and minimize the need for manual installation.

Here’s how to restore packages from your backup on different Linux distributions:

Debian and Ubuntu

To restore packages from the backup file, use:

xargs sudo apt install -y < installed_packages.txt

This command installs all the packages from the saved list, ensuring that your environment is restored exactly as it was.

Red Hat-based systems

On Fedora, CentOS, or RHEL, run:

xargs sudo dnf install -y < installed_packages.txt

This will reinstall the packages from your backup, making system recovery quick and efficient.

Arch-based systems

On Arch Linux, run:

sudo pacman -S --needed - < installed_packages.txt

This ensures that only missing packages are reinstalled, preventing unnecessary reinstalls.

Conclusion

Regularly taking the time to check installed packages Linux is essential to keep your system secure and running smoothly.

Whether you prefer the precision of command-line tools or the ease of graphical interfaces, knowing how to check if a package is installed in Linux ensures that you always have a clear picture of your software environment.

By mastering these techniques, you can effortlessly Linux check installed packages to troubleshoot issues, update dependencies, and maintain overall system health.

This proactive approach not only optimizes performance but also strengthens your infrastructure against potential risks.

Leave a Reply

Your email address will not be published. Required fields are marked.