Använda aptitude från kommandoraden

In addition to its “visual” interface described in the previous section, aptitude can be used to manage packages directly from the command-line in the same way that you would use apt-get. This section covers the most common aptitude command-line actions; for more information, see the aptitude command-line reference.

In general, a command-line invocation of aptitude will look like this:

aptitude action [arguments...]

action tells aptitude what action it is to take; the remaining arguments are used in an option-specific fashion. Typically they will consist of package names and command-line switches[4].

De mest viktiga åtgärderna är:

aptitude update

This command updates the package lists, as if you had entered the visual interface and pressed u.

aptitude upgrade

This command will upgrade as many packages as possible. If there are dependency problems, it will avoid upgrading packages (rather than, for instance, removing them).

aptitude dist-upgrade

This command will also attempt to upgrade packages, but it is more aggressive about solving dependency problems: it will install and remove packages until all dependencies are satisfied. Because of the nature of this command, it is possible that it will do undesirable things, and so you should be careful when using it.

aptitude [ install | remove | purge ] paket1 [paket2...]

Dessa kommandon installerar, tar bort, eller rensar[5] the specified packages. “Installing” a package which is already installed but can be upgraded will cause it to be upgraded.

aptitude search mönster1 [mönster2...]

This command searches for packages whose name contains any of the given patterns, printing the result to the terminal. In addition to just being a string of text, each pattern can be a search pattern as described in “Sökmönster”. [6]

aptitude show paket1 [paket2...]

Skriver ut information om varje paket till terminalen.

The commands that install, upgrade, and remove packages all accept the parameter “-s”, which stands for “simulate”. When “-s” is passed on the command line, the program performs all the actions it would normally perform, but does not actually download or install/remove any files.

aptitude will sometimes present a prompt like this:

The following NEW packages will be automatically installed:
  space-orbit-common 
The following NEW packages will be installed:
  space-orbit space-orbit-common 
0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 3200kB of archives. After unpacking 8413kB will be used.

Do you want to continue? [Y/n/?]

In addition to the obvious options of “Yes” and “No”, a number of commands are available which can be used to change the information displayed at the prompt, or to specify further actions. For instance, typing “s” will display or hide information about how much space each package will use:

Do you want to continue? [Y/n/?] s

Size changes will be shown.

The following NEW packages will be automatically installed:
  space-orbit-common <+8020kB> 
The following NEW packages will be installed:
  space-orbit <+393kB> space-orbit-common <+8020kB> 
0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 3200kB of archives. After unpacking 8413kB will be used.
Do you want to continue? [Y/n/?]

Similarly, typing “d” will display information about automatically installed or removed packages:

The following NEW packages will be automatically installed:
  space-orbit-common (D: space-orbit)
The following NEW packages will be installed:
  space-orbit space-orbit-common 
0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 3200kB of archives. After unpacking 8413kB will be used.

This shows that space-orbit-common is being installed because space-orbit depends on it. You can see the entire list of possible entries by entering “?” at the prompt.

If your request violates dependencies in a way that cannot be trivially resolved, aptitude will ask you what to do:

The following packages are BROKEN:
  libsdl1.2debian
The following packages will be REMOVED:
  libsdl1.2debian-all
.
.
.
The following actions will resolve these dependencies:

Install the following packages:
libsdl1.2debian-oss [1.2.7+1.2.8cvs20041007-4.1 (unstable)]

Score is 19

Accept this solution? [Y/n/q/?]

Typing y (or simply pressing enter) will accept the proposed solution. Typing n will display the “next best” solution:

Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

Install the following packages:
libsdl1.2debian-alsa [1.2.7+1.2.8cvs20041007-4.1 (unstable,now)]

Score is 19

Accept this solution? [Y/n/q/?]

Typing q will “give up” and quit the program immediately:

Accept this solution? [Y/n/q/?] q
Abandoning all efforts to resolve these dependencies.
Abort.

As with the main command-line prompt, you can perform a number of additional actions, including manually altering the states of packages, from the dependency resolution prompt. Type ? to see a complete list.

För en komplett dokumentation av kommandoradsfunktionerna i aptitude, se Kommandoradsreferens för aptitude.



[4] A “switch” is a letter preceded by a hyphen: for instance, “-a”, “-v”, etc.

[5] Purging a package removes the package, as well as all its configuration files.

[6] In fact, the same is true of the commands that take packages as arguments, such as install or show.