於 Debian / Ubuntu Linux 想要查詢套件的版本資訊,要怎麼查?
使用 apt / dpkg 查詢套件版本的語法
以 PHP 為例,PHP 要查詢版本的方式如下:
- $ php --version
PHP 5.6.17-0+deb8u1 (cli) (built: Jan 13 2016 09:10:12) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
要查到 5.6.17-0+deb8u1 的資訊,有哪些命令可以使用?
下述整理自此篇文章 How to check Debian/Ubuntu Linux package version using apt-get/aptitude command:(註:此篇文章還有介紹 aptitude)
查詢版本的語法如下:
- apt-cache policy {package}
- apt-cache madison {package}
- dpkg -s {package} | grep -i version
範例:
- $ apt-cache policy php5
php5: 已安裝:5.6.17+dfsg-0+deb8u1 候選: 5.6.17+dfsg-0+deb8u1 版本列表: *** 5.6.17+dfsg-0+deb8u1 0 500 http://ftp.tw.debian.org/debian/ jessie/main amd64 Packages 100 /var/lib/dpkg/status 5.6.14+dfsg-0+deb8u1 0 500 http://security.debian.org/ jessie/updates/main amd64 Packages 5.4.45-0+deb7u2 0 500 http://security.debian.org/ wheezy/updates/main amd64 Packages 5.4.44-0+deb7u1 0 500 http://ftp.tw.debian.org/debian/ wheezy/main amd64 Packages
- $ apt-cache madison php5
php5 | 5.6.17+dfsg-0+deb8u1 | http://ftp.tw.debian.org/debian/ jessie/main amd64 Packages php5 | 5.6.14+dfsg-0+deb8u1 | http://security.debian.org/ jessie/updates/main amd64 Packages php5 | 5.4.45-0+deb7u2 | http://security.debian.org/ wheezy/updates/main amd64 Packages php5 | 5.4.44-0+deb7u1 | http://ftp.tw.debian.org/debian/ wheezy/main amd64 Packages php5 | 5.6.17+dfsg-0+deb8u1 | http://ftp.tw.debian.org/debian/ jessie/main Sources php5 | 5.6.14+dfsg-0+deb8u1 | http://security.debian.org/ jessie/updates/main Sources php5 | 5.4.44-0+deb7u1 | http://ftp.tw.debian.org/debian/ wheezy/main Sources
- $ dpkg -s php5 | grep Version
Version: 5.6.17+dfsg-0+deb8u1