How to Check Installed Package Version in Linux
Direct Answer:
To check the installed package version in Linux, you can use the dpkg or apt-cache command, depending on the package manager used by your Linux distribution.
Methods to Check Installed Package Version in Linux
Linux distributions have different package managers, and each has its own way to check the version of a package. Here are some common methods:
Using dpkg Command
- The
dpkgcommand is used to manage Debian-based package manager. - To check the version of a package using
dpkg, use the following command:dpkg --list | grep <package_name>Replace
<package_name>with the actual name of the package you want to check.
Example:
dpkg --list | grep nginx
This command will list all packages installed on your system and grep will filter the output to show only the packages that match the word nginx. The version of the package will be shown along with other details.
Using apt-cache Command
- The
apt-cachecommand is used to manage APT-based package manager. - To check the version of a package using
apt-cache, use the following command:apt-cache show <package_name>Replace
<package_name>with the actual name of the package you want to check.
Example:
apt-cache show nginx
This command will display detailed information about the package, including its version.
Using package-query Command
- The
package-querycommand is used to query package information. - To check the version of a package using
package-query, use the following command:package-query --show <package_name>Replace
<package_name>with the actual name of the package you want to check.
Example:
package-query --show nginx
This command will display detailed information about the package, including its version.
Using pip and pip3 Commands (For Python Packages)
- If you’re using Python packages, you can check the version using the
piporpip3command. - To check the version of a package using
piporpip3, use the following command:pip <package_name> --versionReplace
<package_name>with the actual name of the package you want to check.
Example:
pip nginx --version
This command will display the version of the package.
Using yum and sudo yum Commands (For RPM-based Distributions)
- If you’re using RPM-based distributions (such as RHEL, CentOS, Fedora), you can check the version using the
yumorsudo yumcommand. - To check the version of a package using
yumorsudo yum, use the following command:yum info <package_name>Replace
<package_name>with the actual name of the package you want to check.
Example:
yum info nginx
This command will display detailed information about the package, including its version.
Tips and Variations
- To get the specific version of a package installed on your system, use the following command:
dpkg --versionThis command will display the version of the
dpkgpackage. - To get the list of all installed packages, use the following command:
dpkg -lThis command will display a list of all packages installed on your system.
- To search for a package, use the following command:
apt-cache search <package_name>Replace
<package_name>with the actual name of the package you want to search for.
Conclusion
In this article, we explored the various ways to check the installed package version in Linux. By using the dpkg, apt-cache, package-query, pip, pip3, and yum commands, you can easily check the version of a package installed on your Linux system. Remember to replace <package_name> with the actual name of the package you want to check, and use the correct command based on your Linux distribution.
