Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to check whether a package is installed in a Debian/Ubuntu system

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to check whether the package is installed in the Debian/Ubuntu system". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to check whether the package is installed in the Debian/Ubuntu system".

There are many ways to check whether the package is installed. I have found 7 commands from which you can choose which one you like to use.

As follows:

Apt-cache: can be used to query APT cache or package metadata.

Apt: a powerful tool for installing, downloading, deleting, searching, and managing packages in Debian-based systems.

Dpkg-query: a tool for querying dpkg databases.

Dpkg: a package management tool for Debian-based systems.

Which: returns the full path of the executable file executed when a command is entered in the terminal.

Whereis: can be used to search for binaries, source files, and help files for specified commands.

Locate: faster than the find command because it uses the updatedb database search, while the find command searches on the real system.

Method 1. Use the apt-cache command

The apt-cache command is used to query APT cache and package metadata from the APT internal database and will search for and display information about the specified package, including installation, package version, source code repository information, and so on.

The following example clearly shows that the nano package has been installed on the system and the corresponding version number of the installation.

# apt-cache policy nanonano: Installed: 2.9.3-2 Candidate: 2.9.3-2 Version table: * * 2.9.3-2 500 500 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 Packages 100 / var/lib/dpkg/status method 2. Use the apt command

Apt is a powerful command-line tool that can be used to install, download, delete, search, manage packages, and query information about packages, similar to underlying access to all features of the libapt-pkg library. It contains some command-line features that are related to package management but are rarely used.

# apt-qq list nanonano/bionic,now 2.9.3-2 amd64 [installed] method 3. Use the dpkg-query command

Dpkg-query is a tool that displays a list of package information in the dpkg database.

The ii column of the output in the following example indicates that the package for the query has been installed.

# dpkg-query-- list | grep-i nanoii nano 2.9.3-2 amd64 small, friendly text editor inspired by Pico method 4. Use the dpkg command

Dpkg (debian package) is a tool for installing, building, deleting, and managing Debian packages, but unlike other package management systems, it cannot automatically download and install packages or package dependencies.

The * * column ii of the output in the following example indicates that the query package has been installed.

# dpkg-l | grep-i nanoii nano 2.9.3-2 amd64 small, friendly text editor inspired by Pico method 5. Use the which command

The which command returns the full path of the executable file executed when the command is entered in the terminal. This is useful when you want to create desktop shortcuts or symbolic links to executable files.

The which command searches only in the directory list configured by the current user's PATH environment variable, not in all users' directories. This means that when you log in to your own account, it will not search in root user files or directories.

If you have the following output for the specified package or executable path, it is installed, otherwise it is not.

# which nano/bin/nano method 6. Use the whereis command

The whereis command is used to search for corresponding program binaries, source files, help files, etc., for the specified command.

If you have the following output for the specified package or executable path, it is installed, otherwise it is not.

# whereis nanonano: / bin/nano / usr/share/nano / usr/share/man/man1/nano.1.gz / usr/share/info/nano.info.gz method 7. Use the locate command

The locate command is faster than the find command because it searches the updatedb database, while the find command searches on the real system.

For getting the specified file, it uses the database instead of searching in a specific directory path.

The locate command is not preinstalled on most systems and needs to be installed manually.

The database used by locate is updated periodically based on scheduled tasks. Of course, we can also update it manually.

If you have the following output for the specified package or executable path, it is installed, otherwise it is not.

# locate-- basename'\ nano'/usr/bin/nano/usr/share/nano/usr/share/doc/nano Thank you for your reading. The above is the content of "how to check whether the package is installed in the Debian/Ubuntu system". After the study of this article, I believe you have a deeper understanding of how to check whether the package is installed in the Debian/Ubuntu system, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report