如何查看 Ubuntu 上安装了哪些软件包?

如何查看 Ubuntu 上安装了哪些软件包?

要查看 Ubuntu 上安装了哪些软件包,可以按照如下的步骤进行操作:

第 1 步:打开终端应用程序或使用 ssh 登录远程服务器。

ssh user@sever-name 

第 2 步:运行以下命令,以列出 Ubuntu 上所有已安装的软件包。

apt list --installed 

第 3 步:要显示满足特定条件的包列表,例如,显示匹配的 apache2 包,请运行 

apt list apache

apt 列出已安装的软件包

我们可以列出 Ubuntu 上可供我们使用的所有软件包:

如何查看 Ubuntu Linux 上安装了哪些软件包?
如何查看 Ubuntu Linux 上安装了哪些软件包?
$ apt list

也可以使用 grep / egrep 命令过滤:

$ apt list | grep nginx

或者

$ apt list | more

但是,可能会在屏幕上看到警告消息:apt 没有稳定的 CLI 界面。在脚本中谨慎使用。

要避免此消息,可以使用 dpkg 命令,如下所示:

$ dpkg --list | grep nginx
$ dpkg --list | more

列出所有已安装的软件包

使用下面的命令查看已安装的所有软件包:

$ apt list --installed

如何找出特定的软件包

运行如下命令:

$ apt list -a pkgNameHere

查看是否安装了 sudo 包。

$ apt list -a sudo

查看是否安装了 mariadb-server 包。

$ apt list -a mariadb-server

Ubuntu 列出已安装的软件包

也可以列出匹配给定模式的已安装软件包。语法是:

dpkg -l pattern
dpkg --list pattern
apt list pattern
apt list --installed pattern

例如,下面的命令。

dpkg --list 'x*'

输出示例:

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  xauth                                          1:1.0.10-1                   amd64                        X authentication utility
ii  xdelta3                                        3.0.11-dfsg-1ubuntu1         amd64                        Diff utility which works with binary files
ii  xdg-user-dirs                                  0.17-1ubuntu1                amd64                        tool to manage well known user directories
un  xflr5                                          <none>                       <none>                       (no description available)
un  xfsdump                                        <none>                       <none>                       (no description available)
ii  xfsprogs                                       4.9.0+nmu1ubuntu2            amd64                        Utilities for managing the XFS filesystem
ii  xkb-data                                       2.23.1-1ubuntu1              all                          X Keyboard Extension (XKB) configuration data
un  xloadimage                                     <none>                       <none>                       (no description available)
un  xorriso                                        <none>                       <none>                       (no description available)
un  xterm                                          <none>                       <none>                       (no description available)
un  xvt                                            <none>                       <none>                       (no description available)
ii  xxd                                            2:8.0.1453-1ubuntu1          amd64                        tool to make (or reverse) a hex dump
un  xz-lzma                                        <none>                       <none>                       (no description available)
ii  xz-utils                                       5.2.2-1.3                    amd64          
  • ii – 表示安装了的包。
  • un – 表示该软件包未安装或处于未知状态。

按安装时间列出安装包

我们可以使用 zgrep 和其他命令的组合如下。

echo "Total installed packages on ${HOSTNAME} :|\
(zgrep " installed " /var/log/dpkg.log* | wc -l)"
Total installed packages on nixcraft-wks01 : 6433

列出它们:

zgrep " installed " /var/log/dpkg.log
/var/log/dpkg.log:2021-05-01 10:30:01 status installed debootstrap:all 1.0.118ubuntu1.4
/var/log/dpkg.log:2021-05-01 10:30:01 status installed man-db:amd64 2.9.1-1
/var/log/dpkg.log:2021-05-05 00:09:57 status installed openvpn:amd64 2.4.7-1ubuntu2.20.04.2
/var/log/dpkg.log:2021-05-05 00:09:57 status installed man-db:amd64 2.9.1-1
/var/log/dpkg.log:2021-05-05 00:09:59 status installed systemd:amd64 245.4-4ubuntu3.6
/var/log/dpkg.log:2021-05-05 21:31:02 status installed python3-libapparmor:amd64 2.13.3-7ubuntu5.1
/var/log/dpkg.log:2021-05-05 21:31:02 status installed python3-apparmor:amd64 2.13.3-7ubuntu5.1
/var/log/dpkg.log:2021-05-05 21:31:02 status installed apparmor-utils:amd64 2.13.3-7ubuntu5.1
/var/log/dpkg.log:2021-05-05 21:31:03 status installed man-db:amd64 2.9.1-1
........
...
......
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed libxfixes3:i386 1:5.0.3-2
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed libnvidia-encode-440:i386 440.100-0ubuntu0.20.04.1
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed libglx-mesa0:i386 20.0.8-0ubuntu1~20.04.1
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed nvidia-driver-440:amd64 440.100-0ubuntu0.20.04.1
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed libglx0:i386 1.3.1-1ubuntu0.20.04.1
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed libgl1:i386 1.3.1-1ubuntu0.20.04.1
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed libnvidia-fbc1-440:i386 440.100-0ubuntu0.20.04.1
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed libnvidia-ifr1-440:i386 440.100-0ubuntu0.20.04.1
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed desktop-file-utils:amd64 0.24-1ubuntu3
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed mime-support:all 3.64ubuntu1
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed gnome-menus:amd64 3.36.0-1ubuntu1
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed libc-bin:amd64 2.31-0ubuntu9
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed man-db:amd64 2.9.1-1
/var/log/dpkg.log.9.gz:2020-08-30 21:28:10 status installed bamfdaemon:amd64 0.5.3+18.04.20180207.2-0ubuntu2
/var/log/dpkg.log.9.gz:2020-08-30 21:28:24 status installed initramfs-tools:all 0.136ubuntu6.2

原创文章,作者:牛奇网,如若转载,请注明出处:https://www.niuqi360.com/linux/how-to-list-all-installed-pakage-in-ubuntu/

发表评论

登录后才能评论