APT (Advanced Packaging Tool)

botond published 2019/01/29, k - 21:23 time

Content

 

Introductory

The APT (Advanced Packaging Tool) is a free and open source software user interface that, in conjunction with system libraries, automatically installs, configures, or removes software packages for Debian and related Linux distributions. APT simplifies the process of managing software on Unix-like computer systems, from purchasing software packages to configuring them to automated installation, either from precompiled files or by compiling and compiling source code.

 

 

Operation and use

APT is a collection of software tools included in a package called apt. Much of apt is a C ++ library and even includes command-line programs for managing software packages, such as: apt, apt-get, apt-cache. The apt package is included with all Debian distributions by default. Apt is up to dpkg can also be seen as a front-end like dselect more user-friendly version. While dpkg handles operations with custom packages, apt tools handle package-to-package relationships, especially dependencies, as well as higher-level versioning decisions (release tracking and package capture).

APT is often considered to be one of Debian's best features, which is subject to strict quality control by Debian developers.

One of the main features of APT is the way dpkg is called - to topologically sort the list of packages to be installed or removed, and to call dpkg in the best possible order. In some cases, use dpkg --force switch. However, this only occurs if the APT cannot calculate whether dpkg requires the forced action to be performed.

Software installation

The user can install multiple packages at once. It is enough to refer to packages only with the names of the packages, for example, in the case of the libc6_1.9.6-2.deb package, it is enough to specify only the name libc6. APT first installs the packages on which the package you want to install depends, if any. This is therefore a key feature of APT-based package managers to avoid package installability due to missing dependencies.

Another important feature of APT is that it can automatically download packages to a predefined range from trunks (repository). These trunks are / Etc / apt / sources.list configuration file. Whatever number of repositories can be specified in this file, APT will obtain the packages you want to install from these locations. The repositories can be on a remote server or even on a local hard drive, flash drive or DVD, and so on. For example, DVDs of complete Debian installation kits also contain a package repository so that the packages required by the system can be accessed without an Internet connection.

APT provides an opportunity for the user to override the package manager’s automated software conflict avoidance decisions. For example, you can specify which version to install for a particular package (eg downgrade). In this case, however, you need to be very careful because the other packages, which depend on the manually selected version of the package, may fail.

Update, upgrade and dist-upgrade

It is easy to update installed packages apt and apt-get uses include:

  • update: Use this command to resynchronize package index files. When run, APT loads a / Etc / apt / sources.list from the configuration file, a list of the specified repositories, and then e.g. On Debian-based systems, it downloads the Packages.gz file from all specified package repositories to provide up-to-date information about new and updated packages.
  • upgrade: Use this command to upgrade all installed packages to the latest version. The system checks the / Etc / apt / sources.list file, and whichever finds an update to an existing installed package will update it. If you do not find a newer version, leave them intact.
  • dist-upgrade: In addition to the update feature, the command also has an intelligent conflict resolution system that can handle changing dependencies efficiently, which means that you first update the dependencies of the most important packages to the detriment of the less important packages if the situation so requires. The packages in this case are also a / Etc / apt / sources.list update based on the libraries in the configuration file.

Update selected packages only

If we don't want to update all the packages at once, but only one or a few, then a --only-upgrade with a switch it is possible to:

apt-get install --only-upgrade <csomag1> <csomag2> <csomag..>

Enter the packages you want to update here, separated by spaces - if you want to update several packages.

Search for packages

When using the APT command line, you can also search for packages, which can be done using the following command:

apt-cache search <csomagnév>

Then the shell releases packages in the configured libraries that are related to the search term.

Install recommended packages

We have the opportunity to recommended also to install packages. Suggested packages are packages that are not part of the software you are installing or dependencies on, but that may be useful when using the programs that you want to install. By default, the apt-get command is just that recommended installs packages in addition to the packages specified as parameters, and you can use the following switch to prompt you to install these recommended packages as well:

apt-get install --install-suggests <csomagnév>

As a result of the switch, the apt-get command considers the proposed packages as dependencies of the packages to be installed, as well as the additional dependencies of the packages that are thus installed.

Reinstalling packages

You may need to reinstall the packages, for example, if you have set up a configuration file, or the program is not working properly, or you just want to get the original settings back. The --reinstall switch is used for this purpose:

apt-get --reinstall install <csomagnév>

Get packet information

You can request detailed version information for both installed and non-installed packages, as well as which of the currently configured packages has been or will be installed. You can get this with the following command:

apt-cache policy <csomagnév>

Fix addiction errors

If installing a downloaded .deb installation package manually with dpkg stops installing due to dependency errors, you can use the following apt command to replace the package dependencies:

sudo apt-get -f install

You can now install the package without any errors.

Install withholding packages

If APT holds some packages when updating packages, then the apt command --with-new-pkgs switch to install hold packages:

sudo apt-get --with-new-pkgs upgrade
sudo apt-get install <visszatartott csomagok listája>

Read more: How to update our hold packages using the APT package manager

Delete packages

If you want to delete packages, you can do so with the following command:

sudo apt-get remove <csomagok listája>

The above command only deletes the package itself. If you want the command to also delete the configuration files of the packages to be deleted, we use this:

sudo apt-get purge <csomagok listája>

Delete unused packages

Automatic cleaning is also possible. Use the following command to delete any packages that are not in use by the system. For example, previous dependency packages that are no longer needed, etc .:

sudo apt-get autoremove

Clear packet cache

To free up space, clear your luggage cache locally:

sudo apt-get clean

 

Configuration and files

The APT package manager configuration file directory is a / Etc / apt. And its configuration program is apt-config. And the detailed configuration is apt-config dump can be queried.

files

  • / Etc / apt / sources.list: List of sources. This specifies the repositories from which APT installs new or updates packages already installed on the system.
  • /etc/apt/sources.list.d/: Additional directory list files can be placed in this directory, which are also read by the package manager to search for packages and package information. This allows you to group different repositories thematically.
  • /etc/apt/apt.conf: APT configuration file.
  • /etc/apt/apt.conf.d/: Additional configuration files.
  • / Etc / apt / preferences: Package version definition file. In this file you can specify that eg. for a given package, which version to download from the package manager, whether to upgrade at all, and from which repository to upgrade, if the package is in multiple libraries.
  • / Var / cache / apt / archives /: Store the packages you have downloaded so far in this directory.
  • / Var / cache / apt / archives / partial /: Temporary storage for packages that are currently being downloaded.
  • / Var / lib / apt / lists /: Here you will find a sources.list Packages list of the repositories configured in the file
  • / Var / lib / apt / lists / partial /: Temporary storage for downloading list of packages.
  • /var/log/dpkg.log: The complete log of operations performed by the package manager, with dates and times recorded.

 

 

source List

APT searches for and finds packages and their dependencies based on the concept of packages. An APT package repository is essentially a directory that contains an index file in addition to the packages. The boot can be on any part of the network or even on a local drive. There are more than 25000 packages in the official Debian project repository.

The APT sources.list You can specify any number of repositories in the file that the package manager uses for queries performed during package updates. Different graphical front-ends allow more convenient editing of the source list file. Once a package repository is set up in the source list (for example, when you install the system), the packages in the repository can be installed without specifying the source and will be updated automatically.

Examples

As an example, a newly installed Debian 8 (Jessie) source list file looks like this:

# deb cdrom:[Debian GNU/Linux 8.10.0 _Jessie_ - Official amd64 NETINST Binary-1 20171209-21:51]/ jessie main

#deb cdrom:[Debian GNU/Linux 8.10.0 _Jessie_ - Official amd64 NETINST Binary-1 20171209-21:51]/ jessie main

deb http://ftp.hu.debian.org/debian/ jessie main
deb-src http://ftp.hu.debian.org/debian/ jessie main

deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main

# jessie-updates, previously known as 'volatile'
deb http://ftp.hu.debian.org/debian/ jessie-updates main
deb-src http://ftp.hu.debian.org/debian/ jessie-updates main

And the Debian 9 (Stretch) source list is:

# deb cdrom:[Debian GNU/Linux 9.6.0 _Stretch_ - Official amd64 NETINST 20181110-11:34]/ stretch main

#deb cdrom:[Debian GNU/Linux 9.6.0 _Stretch_ - Official amd64 NETINST 20181110-11:34]/ stretch main

deb http://ftp.hu.debian.org/debian/ stretch main
deb-src http://ftp.hu.debian.org/debian/ stretch main

deb http://security.debian.org/debian-security stretch/updates main
deb-src http://security.debian.org/debian-security stretch/updates main

# stretch-updates, previously known as 'volatile'
deb http://ftp.hu.debian.org/debian/ stretch-updates main
deb-src http://ftp.hu.debian.org/debian/ stretch-updates main

And the Debian 10 (Buster) source list is:

# 

# deb cdrom:[Debian GNU/Linux 10.1.0 _Buster_ - Official amd64 NETINST 20190908-01:07]/ buster main

#deb cdrom:[Debian GNU/Linux 10.1.0 _Buster_ - Official amd64 NETINST 20190908-01:07]/ buster main

deb http://deb.debian.org/debian/ buster main
deb-src http://deb.debian.org/debian/ buster main

deb http://security.debian.org/debian-security buster/updates main
deb-src http://security.debian.org/debian-security buster/updates main

# buster-updates, previously known as 'volatile'
deb http://deb.debian.org/debian/ buster-updates main
deb-src http://deb.debian.org/debian/ buster-updates main

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.

structure

An entry line consists of:

  • Archive type:
    • deb: The repository contains binary package files (.deb) precompiled for distribution.
    • deb-src: The container contains the source code files for the packages and the control file (.dsc). This allows you to recompile the packages from their source code.
  • Repository URL: This includes the physical URL availability of the repository.
  • distribution: This can be the distribution name of the distribution (e.g. jessie, stretch, buster, sid) or package release class (e.g. oldstable, stable, testing, unstable), depending on what kind of package updates are required (from older stable versions to the latest test versions).
  • components: This can contain one or more of the following values:
    • main: The repository shall contain only DFSG There are packages that comply with the standard, and the dependencies of this package can only come from here. These are packages that are officially part of the Debian system. Therefore, by default, this option is valid in the source list file.
    • contrib: The repository also contains packages that conform to the DFSG standard, but the dependencies of the packages may include packages from outside (eg non-free).
    • non-free: The repository contains packages that are not licensed under the DFSG standard.

APT transport https

By default, APT can only manage libraries over an unencrypted http connection. However, it is apt-transport-https After installing the package you can install / update packages from the libraries available via https:

sudo apt-get install apt-transport-https

Debian Backports

The backports a testing (mostly) and unstable (only in a few cases, such as security updates) is a collection of packages that have been recompiled in a stable environment and do not need new libraries (whenever possible) so that they can run on a stable Debian distribution.

Backports packages are not as extensively tested as Debian stable storage packages, so there is a risk that it will not be compatible with all other Debian components. Therefore, their use is recommended only with caution.

Of the backport packages, it is recommended to use only the absolutely necessary custom backport package instead of the full set, and to use stable versions wherever possible.

The great advantage of using backports is that packets get here much faster than stable storage.

Examples of configuring repositories in the sources.list file in different versions of Debian:

To configure the Debian 8 (Jessie) backports repository:

deb http://archive.debian.org/debian jessie-backports main

To configure the Debian 9 (Stretch) backports repository:

deb http://ftp.debian.org/debian stretch-backports main

To configure the Debian 10 (Buster) backports repository:

deb http://deb.debian.org/debian buster-backports main

After you modify the sources.list file, you should always update the package list:

sudo apt-get update

 

The custom backports package can then be installed in different versions of Debian as follows:

Debian 8 (Jessie):

sudo apt-get install <backports csomagnév> -t jessie-backports

Debian 9 (Stretch):

sudo apt-get install <backports csomagnév> -t stretch-backports

Debian 10 (Buster):

with the apt-get command:

sudo apt-get install <csomagnév>/buster-backports

Or the aptitude command:

sudo aptitude install <package>/buster-backports

 

Debian mirrors

Debian mirrors allow you to get Debian packages from the nearest server. This distributes the load, resulting in higher download speeds.

List of Debian mirrors see this link.

 

 

frontends

There are many frontend options that make the APT package manager more convenient. These include graphical frontend and text mode.

Frontends can have the following features:

  • searching for new packages
  • filtering packages according to several criteria
  • display details of packages
  • installing new packages (including their dependencies)
  • upgrade existing packages
  • delete existing packages
  • full system upgrade

Graphic frontends

The frontend with a graphical interface is characterized by convenient usage, clear appearance, richer filtering and search capabilities.

Synaptic package manager main window

Graphical frontend example: Synaptic package manager

Some example:

  • Synaptic, one of the most common GTK + based graphical interfaces
  • Ubuntu Software Center, a GTK + based graphical interface developed by the Ubuntu project
  • KPackage, part of KDE
  • Adept Package Manager: A graphical interface for KDE
  • GDebi: GTK + based graphical interface, mainly for Ubuntu
  • Cydia: APT-based package manager for jailbroken iOS systems
  • gnome-apt, a GTK + / GNOME widget based graphical interface
  • Muon Software Center, a Qt-based graphical interface

Text mode frontends

Text frontends are character-based interfaces that have the great advantage of being able to run on a console or terminal, making them an effective tool for remote server management.

Aptitude text package frontend

Text mode frontend example: Aptitude

Some example:

  • Aptitude, the console package management interface 
  • Dselect: One of the first console based dpkg interfaces
  • orphaner: This is just an interface for cleaning broken packages