Section 5.4. The APT Commands in Detail


5.4. The APT Commands in Detail

The apt commands are important. You can do more from the command line interface. If you want to take full advantage of the apt system, you'll learn how to use the basic apt commands. While we do not cover all available apt commands in this book, two are critical to anyone interested in patch management for RPM- and DEB-based distributions: apt-cache and apt-get.

There are certainly more apt commands of interest, some of which were covered in Chapter 4. Some are largely limited to Debian-style distributions.

5.4.1. Analyzing apt-cache in Detail

It's worth some trouble to examine what you can do with the apt-cache command. You can review most available options with the apt-cache -h | less command. This list is not complete; you learned about the showgroup and groupnames options earlier in this chapter, as well as search in Chapter 4. Several options are rarely used because other commands may be more useful. For example, while the apt-cache add package command adds a package to the cache, it's best to keep your entire database up to date with the apt-get update command. Therefore, several apt-cache options are not covered in this book.

apt-cache showpkg

When you run the apt-cache showpkg packagename command, apt-cache searches through available package databases, as download from servers and locations specified in /etc/apt/sources.list. One sample with the synaptic package is shown in Figure 5-9.

Figure 5-9. Listing versions and dependencies with apt-cache


Data associated with synaptic is divided into the following five categories:

Versions specifies the different versions of the synaptic package that are available from your repositories.

Reverse depends lists those packages that depend on synaptic, or whatever you're planning to install.

Dependencies specifies those packages that are required before you can install synaptic.

Provides lists packages and key files provided by the package.

Reverse provides specifies packages that depend on what you're installing.

apt-cache showsrc

When you run apt-cache showsrc packagename command, apt-cache searches through available source package databases, as downloaded from source repositories specified in /etc/apt/sources.list; the source repositories in that file should be associated with the deb-src or rpm-src commands.

Among other things, the output includes the name of the source files required to build the binary packages and the Build-Depends, which include those packages and libraries required to build the specific package.

apt-cache show

If you want more information on available packages, the show option is for you. When you run the apt-cache show packagename command, the package does not have to be installed. All you need to do is specify the name of the package and apt-cache searches through the downloaded cache of available packages for dependencies, conflicts, and basic package information. Try it with the package of your choice.

apt-cache depends / rdepends

If you want more information on dependencies, the depends option is for you. When you run the apt-cache depends packagename command, the package does not have to be installed. All you need to do is specify the name of the package and apt-cache searches through the downloaded cache of available packages for dependencies. Try it with the package of your choice.

The rdepends option is relatively straightforwardit provides a list of reverse dependencies, those packages that depend on the package which you've specified.

apt-cache pkgnames

The apt-cache pkgnames command by itself is not useful. It scrolls a very long list of every package available from your repositories. But as a database, it can be powerful. For example, if you want a list of every package with gimp in its name, you'd run the following command:

apt-cache pkgnames | grep gimp 


5.4.2. Analyzing apt-get in Detail

It's worth some trouble to examine what you can do with the apt-get command. You can review most available options with the apt-get -h | less command. This list is not complete; you learned about the mirror-select, showgroup, and groupinstall options earlier in this chapter, as well as update, install, remove, dselect-upgrade, clean, and autoclean options in Chapter 4. Several options that are rarely used are not covered in this book.

Default apt-get options are available either in /etc/apt/apt.conf or the /etc/apt/apt.conf.d directory. Naturally, you can override any defaults in these files with the correct switches.

apt-get switches

Before we discuss options, there are a number of switches available for apt-get, as shown in Table 5-3. You can use it with the options associated with apt-get, as described in this section and elsewhere in this book.

Table 5-3. apt-get switches

Switch

Description

-d

Performs downloads without installing any packages

-f

Attempts to repair broken dependencies

-m

Ignores and does not download any missing packages or those which are download with errors

-q

Silences any messages during the download and installation process

-s

Simulates the download and installation

-y

Answers all prompts with a "yes"

-u

Lists all upgraded packages

-V

Displays full version numbers (current and future) for upgrades

--no-upgrade

Does not perform upgrades

--purge

Purges packages to be deleted, including applicable configuration files

--reinstall

Reinstalls packages which are already at the latest version; replaces all but missing configuration files

--no-remove

If packages are to be removed, the process aborts automatically

--config-file

If you've set up an alternative to apt.conf, specify it with this switch


apt-get upgrade

I don't generally recommend the use of the apt-get upgrade command, because it leads to upgrades to newer versions of most currently installed packages. However, this option does not remove any installed packages; any upgrades which require removals aren't run.

apt-get dist-upgrade

If you're prepared to upgrade your system, the apt-get dist-upgrade command may be for you. It provides the "smart upgrade" option described in Chapter 4 available through the Synaptic Package Manager. Detailed options involve the use of the apt-preferences command available only for Debian-type distributions. Because upgrades often involve hundreds of packages, some conflicts may be inevitable. With the smart upgrade features, upgrades of more important packages take priority.

In some cases, the -f switch can help by repairing broken dependencies. Other switches described in Table 5-3 may also help.

apt-get check

If you're having problems with dependencies, run the apt-get check command. It updates the current cache of packages and lists any unmet dependencies.

5.4.3. Debian-Only apt Commands

There are several apt-related commands generally available only for Debian-type distributions. While Conectiva has ported most of these commands to its RPM-based distribution, they are generally not available for other RPM-based distributions. They include several commands described in Chapter 4, including

apt-build downloads source and build packages associated with a specific download, optimized for a specific architecture.

apt-ftparchive generates index files for apt-based archives. The corresponding RPM-based command, as described earlier, is genbasedir, which is part of the apt-server RPM.

apt-howto includes the latest version of the APT HOWTO; it is also available from www.debian.org/doc/manuals/apt-howto.

apt-listbugs is normally not run by itself; when installed, it's automatically invoked by other apt commands to download available bug reports.

5.4.4. RPM-Only apt Commands

There are three apt scripts available only for RPM-based distributions. As of this writing, they have not been ported to Debian-based distributions. Depending on the distribution, they may be available as part of the apt or the apt-server RPM packages. These scripts are as follows:

genbasedir was described earlier in this chapter; it allows you to create a database suitable for an apt repository.

genpkglist is run via genbasedir to create package list archives.

gensrclist is also run via genbasedir to create source package archives.



Linux(r) Patch Management(c) Keeping Linux(r) Systems Up To Date
Linux Patch Management: Keeping Linux Systems Up To Date
ISBN: 0132366754
EAN: 2147483647
Year: 2006
Pages: 80
Authors: Michael Jang

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net