2015年9月16日 星期三

[Linux 文章收集] Find out if package is installed in Linux

Source From Here 
Preface 
The command to finding out if package is installed in Linux is depend upon your Linux distribution. Following are commands for different distributions. 

Debian / Ubuntu Linux 
Use dpkg command, which is package manager for Debian. Suppose you want to find out sudo is installed or not, type command: 
root@ubuntu:~# dpkg -s sudo
Package: sudo
Status: install ok installed
Priority: optional
Section: admin
Installed-Size: 1508
Maintainer: Ubuntu Developers
Architecture: amd64
Version: 1.8.9p5-1ubuntu1.1
Replaces: sudo-ldap
Depends: libc6 (>= 2.15), libpam0g (>= 0.99.7.1), libselinux1 (>= 1.32), libpam-modules
Conflicts: sudo-ldap
Conffiles:
/etc/init.d/sudo 69497d0565055f626ee2bc84f818ce0f
/etc/sudoers e8e73f16ed73309df7574c12fbcc0af7
/etc/pam.d/sudo 665a6dead44ff792cfad6b0faa10a621
/etc/sudoers.d/README 8d3cf36d1713f40a0ddc38e1b21a51b6
Description: Provide limited super user privileges to specific users
Sudo is a program designed to allow a sysadmin to give limited root
privileges to users and log root activity. The basic philosophy is to give
as few privileges as possible but still allow people to get their work done.
.
This version is built with minimal shared library dependencies, use the
sudo-ldap package instead if you need LDAP support for sudoers.
Original-Maintainer: Bdale Garbee

Use file /var/lib/dpkg/available to find out all package names available to you. Or you can use following command (list all packages in /var/lib/dpkg/status): 
root@ubuntu:~# dpkg-query -l
...
||/ Name Version Architecture Description
+++-==============================-====================-====================
ii account-plugin-aim 3.8.6-0ubuntu9.2 amd64 Messaging account plugin for AIM
...

root@ubuntu:~# dpkg-query -l 'libc6*' // You can also try to match package name using wild cards
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============================-====================-====================
ii libc6:amd64 2.19-0ubuntu6.6 amd64 Embedded GNU C Library: Shared libraries
...

Once you've found package name, use the following command to get exact status (whether it is installed or not): 
root@ubuntu:~# dpkg-query -W -f='${Status} ${Version}\n' sudo
install ok installed 1.8.9p5-1ubuntu1.1

Red Hat Enterprise / Fedora Linux / Suse Linux / Cent OS 
Under Red Hat/Fedora Linux use rpm command: 
$ rpm -qa | grep {package-name}

For example find out package mutt installed or not: 
$ rpm -qa | grep mutt
mutt-1.4.1-10

Supplement 
20 Practical Examples of RPM Commands in Linux 
rpm command cheat sheet for Linux 

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...