Читать книгу Mastering Linux System Administration - Richard Blum - Страница 57

Managing Packages with apt

Оглавление

A common task that Linux system administrators face is to determine what packages are already installed on the system. The apt list command displays all the packages available in the repository, but by adding the ‐‐installed option, you can limit the output to only those packages already installed on your system.

$ apt --installed list Listing… accountsservice/focal-updates,focal-security,now 0.6.55-0ubuntu12~20.04.4 amd64 [installed,automatic] adduser/focal,now 3.118ubuntu2 all [installed,automatic] alsa-topology-conf/focal,now 1.2.2-1 all [installed,automatic] alsa-ucm-conf/focal-updates,now 1.2.2-1ubuntu0.4 all [installed,automatic] amd64-microcode/focal,now 3.20191218.1ubuntu1 amd64 [installed,automatic] apparmor/focal-updates,now 2.13.3-7ubuntu5.1 amd64 [installed,automatic] apport-symptoms/focal,now 0.23 all [installed,automatic] apport/focal-updates,focal-security,now 2.20.11-0ubuntu27.12 all [installed,automatic] … $

As you can guess, the list of installed packages will be long, so we've abbreviated the output to show just a sample of what the output looks like. Next to the package name is additional information about the package, such as the version name, and whether the package is installed and flagged for automatic upgrades.

If you already know the package name and want to quickly display detailed information about it, use the show command.

apt show package_name

Here's an example of displaying the details of the package zsh :

$ apt show zsh Package: zsh Version: 5.8-3ubuntu1 Priority: optional Section: shells Origin: Ubuntu Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Original-Maintainer: Debian Zsh Maintainers <pkg-zsh-devel@lists.alioth.debian.org> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 2,390 kB Depends: zsh-common (= 5.8-3ubuntu1), libc6 (>= 2.29), libcap2 (>= 1:2.10), libtinfo6 (>= 6) Recommends: libgdbm6 (>= 1.16), libncursesw6 (>= 6), libpcre3 Suggests: zsh-doc Homepage: https://www.zsh.org/ Download-Size: 707 kB APT-Sources: http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages Description: shell with lots of features Zsh is a UNIX command interpreter (shell) usable as an interactive login shell and as a shell script command processor. Of the standard shells, zsh most closely resembles ksh but includes many enhancements. Zsh has command-line editing, built-in spelling correction, programmable command completion, shell functions (with autoloading), a history mechanism, and a host of other features. $

The apt show command does not indicate that the package is installed on the system. It shows only detailed package information from the software repository. One detail you cannot get with apt is a listing of all the files associated with a particular software package. To get this list, you will need to go to the dpkg command itself.

dpkg -L package_name

Here's an example of using dpkg to list all the files installed as part of the apt‐utils package:

$ dpkg -L apt-utils /. /usr /usr/bin /usr/bin/apt-extracttemplates /usr/bin/apt-ftparchive /usr/bin/apt-sortpkgs /usr/lib /usr/lib/apt /usr/lib/apt/planners /usr/lib/apt/planners/apt /usr/lib/apt/solvers /usr/lib/apt/solvers/apt … $

You can also do the reverse—find what package a particular file belongs to, as shown here:

dpkg --search absolute_file_name

Note that you need to use an absolute file reference for this to work.

$ dpkg --search /usr/bin/apt-ftparchive apt-utils: /usr/bin/apt-ftparchive $

The output shows the apt‐ftparchive file was installed as part of the apt‐utils package.

Mastering Linux System Administration

Подняться наверх