debian ubuntu
While working on the instructions for compiling MonoDevelop from source, I relied heavily on the dpkg and apt-cache commands to tell me what was already installed vs what packages were available in the repository. After completing that article it occurred to me that I should explain how to show what packages are currently installed… so here we are.
在处理从源代码编译MonoDevelop的说明时,我严重依赖dpkg和apt-cache命令来告诉我已经安装了什么以及资源库中提供了哪些软件包。 完成该文章后,我想到应该解释如何显示当前安装了哪些软件包……就在这里。
The command we need to use is dpkg –get-selections, which will give us a list of all the currently installed packages.
我们需要使用的命令是dpkg –get-selections,它将为我们提供所有当前已安装软件包的列表。
$ dpkg --get-selections adduser install alsa-base install alsa-utils install apache2 install apache2-mpm-prefork install apache2-utils install apache2.2-common install apt install apt-utils install
$ dpkg --get-selections adduser install alsa-base install alsa-utils install apache2 install apache2-mpm-prefork install apache2-utils install apache2.2-common install apt install apt-utils install
The full list can be long and unwieldy, so it’s much easier to filter through grep to get results for the exact package you need. For instance, I wanted to see which php packages I had already installed through apt-get:
完整的列表可能很长而且很笨拙,因此通过grep筛选以获取所需的确切软件包的结果要容易得多。 例如,我想看看我已经通过apt-get安装了哪些php软件包:
dpkg --get-selections | grep php
libapache2-mod-php5 install php-db install php-pear install php-sqlite3 install php5 install php5-cli install php5-common install php5-gd install php5-memcache install php5-mysql install php5-sqlite install php5-sqlite3 install php5-xsl install
libapache2-mod-php5 install php-db install php-pear install php-sqlite3 install php5 install php5-cli install php5-common install php5-gd install php5-memcache install php5-mysql install php5-sqlite install php5-sqlite3 install php5-xsl install
For extra credit, you can find the locations of the files within a package from the list by using the dpkg -L command, such as:
为了获得更多的荣誉,您可以使用dpkg -L命令从列表中找到文件包中文件的位置,例如:
dpkg -L php5-gd /. /usr /usr/lib /usr/lib/php5 /usr/lib/php5/20060613 /usr/lib/php5/20060613/gd.so /usr/share /usr/share/doc /etc /etc/php5 /etc/php5/conf.d /etc/php5/conf.d/gd.ini /usr/share/doc/php5-gd
Now I can take a look at the gd.ini file and change some settings around…
现在,我可以看一下gd.ini文件并更改一些设置...
翻译自: https://www.howtogeek.com/howto/linux/show-the-list-of-installed-packages-on-ubuntu-or-debian/
debian ubuntu