How to Check if a Package Is Installed on Debian, RedHat And Derivative Systems

Verifying whether a package is installed on your Linux system is a fundamental step, especially when debugging issues or managing configurations. The process varies depending on the package manager used by your distribution.

For example, Debian-based systems like Ubuntu and Linux Mint use dpkg, while Fedora and Red Hat-based systems use rpm. If you’re also exploring alternatives like AlmaLinux, check out this overview of AlmaLinux OS 10.

Before attempting to install new software or investigating why a command fails, checking whether the software is already present can save time and prevent redundancy. For more command-line productivity tips, consider reading about passwordless sudo for root access, changing a user’s default shell, opening files from the terminal, automating inputs with the yes command, or installing a new kernel on Ubuntu.

Checking if a Package is Installed on Debian/Ubuntu

On Debian-based distributions, use the dpkg -l | grep package_name command to check for an installed package. Here’s an example using vim:

dpkg -l | grep vim

Example output:

ii  vim           2:9.0.1670-1ubuntu2       amd64        Vi IMproved - enhanced vi editor
ii  vim-common    2:9.0.1670-1ubuntu2       all          Vi IMproved - Common files
ii  vim-runtime   2:9.0.1670-1ubuntu2       all          Vi IMproved - Runtime files

If there’s no output, the package is not installed. To list all installed packages:

dpkg -l | less

Checking if a Package is Installed on Fedora/CentOS

For RPM-based systems like Fedora or CentOS, use the following command:

rpm -qa | grep vim

Example output:

vim-enhanced-9.0.2112-1.fc39.x86_64
vim-common-9.0.2112-1.fc39.x86_64
vim-filesystem-9.0.2112-1.fc39.noarch

If the command returns no results, the package is not installed. To browse all installed packages:

rpm -qa | less

Understanding these basic checks can save you time and frustration, especially when working in complex environments or managing multiple systems. They’re also crucial for ensuring consistency in automation scripts or server provisioning workflows.

Mastering package management on Linux is a foundational skill that will serve you well across virtually all distributions. Add these quick checks to your toolkit, and you’ll streamline your system administration tasks considerably.

5 Comments

  1. Pingback: How to Restrict Users to FTP Access Only on Linux – Linux Node

Leave a Reply

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