Ubuntu 16.04 is out now and brings many very interesting changes to its users, such as support for the BSD file system - ZFS, support for the new package installation technology - snap and many others. But one thing you probably haven't heard of yet, because little things like that get lost a lot, is apt.

What is apt? This is a new package manager for Ubuntu ready to take on the job of apt-get. It was designed to be friendlier, more efficient and more secure. So what did Canonical have in mind when they introduced the new package manager? Are there really differences between apt vs apt-get? This is what we will find out in today's article.

Apt was implemented to make it easier to work with the package manager and to combine multiple commands into one. The functionality of apt-get has been redesigned to work correctly in apt.

Although these new commands are designed to work similarly to apt-get, they are based on new code to interact with packages.

The main reason for introducing apt is the very essence of Ubuntu - simplicity and ease of use. Whether people want to admit it or not, apt-get is an obsolete tool and its practicality is highly questionable. Apt has been designed from the ground up to be even more efficient and designed to be enjoyable for new users.

apt vs apt-get. What are the differences?

apt or apt-get. So what is the difference between these two solutions? For starters, you no longer need to use apt-get autoremove to clear the package cache. Also you don't need to type apt-cache search to find packages.

These commands have been replaced by apt search and apt remove. The main difference of apt is that it replaces all the commands apt-get, apt-cache, etc. All the functionality is combined in one utility.

Although this is not the only difference from apt-get. Software installation progress bars have been improved here. It also supports some additions that make the utility smarter than the previous one. For example, when updating software sources with apt-get, there is no easy way to list the packages available for updating. You can just sudo apt-get update and then:

sudo apt list-upgradable

Of course, little things, but nice. New, modern output colors have also been added, and overall package installation is faster. Canonical is in no hurry to move away from apt-get, but they will make it a positive change.

New Apt Commands

Here is a list of commands supported by apt, taken directly from the --help output. These commands are very similar to the implementation of apt-get and apt-cache, but are more organized and grouped.

Basic commands:

  • list- package list
  • search- search for packages by name
  • show- show detailed information about the package
  • update- update lists of available packages
  • install- install the package
  • remove- remove package
  • upgrade- install available new package versions
  • full upgrade- complete system update
  • edit-sources- edit software sources file

For more information, run man apt in a terminal. The information stored there will help you thoroughly study the new utility.

conclusions

Apt-get is a tried and true part of a software manager. This tool has been around for a long time and comes by default in many releases of Ubuntu and Debian. We have always used it when we needed to update something, update software, or even just clean up the system of garbage.

However, it is getting old. The package manager no longer meets all the needs of users, and therefore it is slowly being replaced by apt. Ubuntu developers understand that they need to update their package manager to make it simpler, more elegant, and more secure. But while both utilities exist in the system, it is up to you to choose whether to use apt or apt-get. Will you be using the new package manager? Or are you already using it?

APT (Advanced Packaging Tool) is a utility in Debian-like systems that installs, updates packages, and keeps track of their dependencies. The purpose of creating the program was to automate the process of package management, in particular, updating and maintaining dependencies, which, in the case of direct work with the dpkg manager, took place manually. Packages are directly manipulated using the program apt-get, the main commands for working with which will be discussed below.

General structure of apt-get command

apt-get [options] command package1 package2 ... packageN

The following options may be useful when working with apt-get:

Updating the list of packages available for installation

This action is performed using the command:

apt-get update

Updating the list is especially important if you want to install the most recent and stable version of a package. When this command is executed, the program scans the archives specified in the file /etc/apt/sources.list.

Package installation

To install a package, use the command:

apt-get install packagename

As a result, APT will search for the latest version of the specified package and check if it has any dependencies. If there are dependencies, a list of them and an installation suggestion will be displayed.

[email protected]:~# apt-get install aee Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 The following NEW packages will be installed: aee libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 0 upgraded, 6 newly installed, 0 to remove and 44 not upgraded. Need to get 181 kB/1297 kB of archives. After this operation, 4366 kB of additional disk space will be used. Do you want to continue?

If there are no dependencies, the installation process will happen automatically without any prompts.

Also, at the time of entering the command to install packages, you can specify the names of the packages that need to be removed. To do this, add a hyphen to the end of the name of the package to be removed. An example of such an install/uninstall method is shown below:

[email protected]:~# apt-get install aee htop- Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 The following packages will be REMOVED : htop The following NEW packages will be installed: aee libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 0 upgraded, 6 newly installed, 1 to remove and 43 not upgraded. Need to get 1297 kB of archives. After this operation, 4157 kB of additional disk space will be used. Do you want to continue?

As you can see from the example, the aee package is prepared for installation, while the htop package is prepared for removal.

Reinstalling a package

If the need arises to reinstall the package (corruption of files, the appearance of a newer version), it can be done using the following command:

apt-get --reinstall install packagename

Removing a package

There are two options for removing packages:

  • Removing the package except for configuration files (if any).

Typically, this option may be required if you plan to reinstall this package in the future. This removal method is performed by the command:

apt-get remove packagename

It is also worth noting that if the package being removed has dependencies, it will be removed along with them.

  • Complete removal of a package

Unlike the first method, all files that are related to the package being removed will be deleted, including configuration files. In this case, the command is used:

apt-get --purge remove packagename

Packages that are marked for complete removal have a "*" at the end of their name.

  • Uninstall and install in one command

In addition, when uninstalling, you can mark the list of packages to be installed. To do this, you need to specify " + ” at the end of the package name. An example of such a command is shown below:

[email protected]:~# apt-get --purge remove aee screen+ Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: aee* The following NEW packages will be installed: screen 0 upgraded, 1 newly installed, 1 to remove and 43 not upgraded. Need to get 624 kB of archives. After this operation, 975 kB of additional disk space will be used. Do you want to continue?

Updating packages

apt-get update

This will update information about available packages and their versions. After executing this command, you can proceed directly to updating the installed packages on the system. This is done with the command:

apt-get -u upgrade

Specified parameter -u is used to get a complete list of packages that will be prepared for the update.

Distribution version update

If a new version of the OS you have installed appears, you can “upgrade” the entire system using the command.

To automate the process of installing, removing and updating software packages in a number of distributions linux applied Advanced software package management systemAPT (Advanced Packaging Tool). Automation is achieved by creating one or more external repositories in which software packages are stored and against which the packages installed in the system are checked. Repositories can contain both the official version of the distribution, updated by its developers as new versions of programs are released, and local developments.

Thus, available APT there are two databases: one describes the packages installed in the system, the second - an external repository. APT monitors the integrity of the installed system and, in case of discrepancies in package dependencies, is guided by information about the external repository to resolve conflicts and find the correct way to eliminate them.

APT was originally designed as independent of a specific method of working with packages installed in the system, which allowed developers from a Brazilian company Connectiva implement package manager support in it RPM. Thus, users based on RPM distributions (Fedora Core, Mandriva, ASP Linux, ALT Linux) have been able to use this powerful tool.

GUI for APT

Graphical shell for APT is synaptic based on a powerful packet filtering system. This greatly simplifies the interface, while also providing a great deal of flexibility when navigating through very long lists of packages.

Usage APT

System APT consists of several utilities. The main and most commonly used package management utility is apt-get , which automatically detects dependencies between packages and strictly enforces them when performing any of the following operations: installing, removing or updating packages.

apt-get allows you to install packages into your system that require other packages that are not yet installed. In this case, it determines which packages need to be installed and installs them using all available repositories. In order for apt-get to use a particular repository, information about it must be placed in the /etc/apt/sources.list file and run the command

~# apt-get update

This command must also be run every time you are going to work with the repository after a long break, because when searching for packages APT should be guided by a database that reflects the current state of the repository. Such a database is created anew each time a change occurs in the repository: a package is added, removed, or renamed. To speed up the work, apt-get keeps a local copy of the database, which after a while may no longer correspond to the real state of the repository.

The distribution CDs can also be used as a source of packages, since each disk contains everything necessary for APT information about the packages it contains. To do this, you need to use the apt-cdrom utility with a single add parameter. The operation should be repeated for the CD from the set. After that, an entry about the connected disk will appear in /etc/apt/sources.list.

If there is no network connection, the lines in /etc/apt/sources.list that talk about resources available over the network should be commented out.

Search for packages

If there is no exact package name, you can use the apt-cache utility to search for it, which allows you to search not only by the package name, but also by its description:

~$ apt-cache search wine wine-utils - Wine Emulator (Additional Programs) libwine-arts - arts support library for wine libwine-twain - twain support library for wine libwine-devel - Headers for libwine-devel libwine - Main library for wine wine - Environment for running Windows programs (build from Etersoft)

In order to learn more about each of the packages found and read its description, you can use the apt-cache show command, which will show information about the package from the repository:

~$ apt-cache show wine-utils Package: wine-utils Section: Emulators Installed Size: 8700 Maintainer: Vitaly Lipatov Version: 20040716-alt1 Pre-Depends: rpmlib(PayloadFilesHavePrefix) (<= 4.0-1), rpmlib(CompressedFileNames) (<= 3.0.4-1) Depends: wine (= 20040716-alt1), libc.so.6, libc.so.6(GLIBC_2.0), libc.so.6(GLIBC_2.1), libc.so.6(GLIBC_2.1.3), libc.so.6(GLIBC_2.2), libc.so.6(GLIBC_2.3), libm.so.6, libm.so.6(GLIBC_2.0), libwine.so.1, libwine.so.1(WINE_1.0), perl-base, sh Provides: wine-utils (= 20040716-alt1) Architecture: i586 Size: 1575076 MD5Sum: Filename: wine-utils-20040716-alt1.i586.rpm Description: Эмулятор Wine (Дополнительные программы) This is an ALPHA release of Wine, the MS-Windows emulator. This is still a developers release and many applications may still not work. This package consists many of the utilities provided by wine, both for compiling source using winelib and for running wine. This package is not strictly necessary. Wine is often updated.

Getting package dependencies:

~$ apt-cache depends wine-utils wine-utils-20040716-alt1 Requires: wine = 20040716-alt1 Requires: glibc-core-6:2.3.3.200406160000-alt1 Requires: glibc-core-6:2.3.3.200406160000-alt1 Requires: glibc-core-6:2.3.3.200406160000-alt1 Requires: glibc-core-6:2.3.3.200406160000-alt1 Requires: glibc-core-6:2.3.3.200406160000-alt1 Requires: glibc-core-6:2.3.3.200406160000-alt1 Requires: glibc-core-6:2.3.3.200406160000-alt1 Requires: libwine-20060610-alt0.M24.1 Requires: libwine-20060610-alt0.M24.1 Requires: perl-base Requires: sh

Shows dependencies not only on files, but also on the resulting packages that include these files, which is very convenient for analyzing possible installation difficulties.

Installing or updating a package

Installing a package with APT executed by the command:

~# apt-get install packagename

If the result of operations with packages without using APT system integrity is compromised, apt-get will refuse to install, remove, or update. In such a situation, you should repeat the operation with the -f option, which forces apt-get to fix the broken dependencies (if possible), while monitoring the messages issued by apt-get , analyzing them and strictly following the program's recommendations.

Reinstalling the package:

~# apt-get install packagename --reinstall

A useful mode that allows you to fix the errors of the administrator and package builder.

If you are unsure whether the operation will keep the system running, run apt-get with the -s option.

In this case, a report on the update operation will be shown, but the update itself will not be performed:

~# apt-get install -s packagename

Removing an installed package

To remove a package use the command

~# apt-get remove packagename

To preserve the integrity of the system, all packages that depend on the one being removed will also be removed: if a component (for example, a library) necessary for the application to work is missing, then the application itself becomes useless. In the case of removing a package related to the basic components of the system, apt-get will require additional confirmation of the operation performed in order to prevent a possible accidental error.

Update all installed packages

To update all installed packages use the command

~# apt-get upgrade

It allows you to update only those packages for which there are new versions in the repositories listed in /etc/apt/sources.list ; this will not remove any other packages from the system.

This method is useful when working with stable application packages that are known to change little when they change versions.

Changes to package names or changes to package dependencies are not handled by apt-get upgrade. Such situations are resolved in the distribution-wide upgrade mode:

~# apt-get dist-upgrade

In case of updating the entire distribution APT will compare the system with the repository and remove obsolete packages, install new versions of packages present in the system, and also track situations with package renames or changes in dependencies between old and new versions of programs. Anything that needs to be installed (or removed) in addition to what is already on the system will be indicated in the apt-get report, which APT will precede the update itself.

Setting APT

APT allows you to interact with the repository using various access protocols. The most popular of them are http and FTP.

Working with the local repository and remote ones is described in detail in the section

For a long time, I was gnawed by ignorance of how to do some elementary things in Debian package managers, but, as often happens, there was no one nearby to ask, and my hands didn’t reach writing somewhere. And finally, the questions matured and I wrote my question to the Debian mailing list. Naturally, it turned out that I missed something obvious, but I also learned a lot of non-obvious usefulness, so I decided to sketch out a cheat sheet, maybe someone will come in handy.

Brief Debian Administrator Help

Basic and well-known
Getting information about new/updated packages
sudo aptitude update
Update
sudo aptitude safe-upgrade
Search for a package by package names
aptitude search key_word
Search for a package by exact name
aptitude search "^name$"
Search by description
aptitude search "?description("key_word")"
Package Information
aptitude show package_name
Installation
sudo aptitude install package_name
Removal
sudo aptitude remove package_name
Complete removal (along with configs)
sudo aptitude purge package_name
Clear cache of downloaded packages (free up space)
aptitude autoclean # will only remove outdated packages aptitude clean # will clear the entire cache
Installing a separately downloaded / created package (to create a package from third-party sources, you need to use the checkinstall utility with the -D flag)
sudo dpkg -i /path/to/package.deb
For additional information
man aptitude sudo aptitude install aptitude-doc-en
and look at the documentation (/usr/share/doc/aptitude/html/en/index.html), for quick help on search patterns, go here - /usr/share/doc/aptitude/html/en/ch02s04.html. If you are too lazy to put the dock, then it is on the network.
Introductory on Debian Wiki: wiki.debian.org/Aptitude
And now something that is not obvious or requires a full reading of the documentation
1. How can I see which packages will be updated after update?
aptitude search ?upgradable
you can also use (if you put)
sudo daptup
but after installing it, the usual update will behave in the same way

2. How can I find out what has changed in the packages that will be updated?
You can try
sudo aptitude changelog package_name
for each package.
But it’s better to install apt-listchanges, then before any updates are installed, a list of changes will be shown, the default settings are not very convenient, so it’s better to reconfigure for yourself, for example, select the output format (while I’m using text, pager is probably better for large updates), don’t send emails, ask for confirmation, display all the information. To do this, you need to run
sudo dpkg-reconfigure apt-listchanges
3. What should I do if the update breaks something and needs to be rolled back?
There is no rollback, you can try to find the previous version of the package
sudo aptitude version package_name
and install it
sudo aptitude install package_name=version
4. How to find all manually installed packages?
there is a variant of the command (aptitude search "~i!~M"), but unfortunately it does not give the desired result, so the question remains open, there are a lot of ways based on the analysis of logs
/var/log/aptitude (+ rotated chunks) /var/log/installer/initial-status.gz /var/log/dpkg.log (+ rotated chunks)
but there is no simple and ready-made solution, yes, information can theoretically be lost during rotations, you need to configure

5. How to view the list of files in a package?
if the package is installed
dpkg -L package_name
for any packages put apt-file and
apt-file list package_name
6. How can I see which package a file belongs to?
dpkg -S file_name
7. How to remove all packages where there is a key in the package name?
sudo aptitude purge ~ikey
8. How to remove the remaining configs from the removed packages?
sudo aptitude purge ~c
9. How to find the package package that contains the lib.so file:
apt-file search lib.so
10. How to convert rpm package to deb?
alien --to-deb /path/to/file.rpm
11. How to find the list of installed kernels?
dpkg --list linux-* | grep ii
12. How to install a package from testing or experimental?
You need to write on this topic separately (for example, like this), but in short, there are commands for this
sudo aptitude -t testing package_name
or
sudo aptitude package_name/testing
13. How can I remove a metapackage but keep one of the dependencies?
you will have to read the documentation about the unmarkauto key or look here.

14. How to find out what got into the file system past the package management system?
There is a cruft utility, although the issue of interpreting the results (report file) is still open
sudo cruft -d / -r report --ignore /home --ignore /var --ignore /tmp
15. What are the additional repositories?
Debian - wiki.debian.org/UnofficialRepositories
Ubuntu - lots of stuff

APT (short for Advanced Packaging Tool) is a set of utilities for installing, uninstalling, upgrading, finding packages on Linux, and managing repositories. APT is also called a package manager.

APT uses package repositories. The list of repositories for APT is stored in a file /etc/apt/sources.list, as well as in the directory /etc/apt/sources.list.d/.

APT is used in distributions based on Dedian and Ubuntu.

There are various utilities for managing APT, but the most popular ones are the apt-get and apt command-line utilities.

In this article, we will look at how to use the apt command, and also learn how apt differs from apt-get.

What is the difference between apt and apt-get

To briefly answer a very popular question, what is the difference between apt and apt-get commands?

apt is a utility that appeared as an alternative to apt-get. It performs almost all the same functions as apt-get, but it is easier and clearer to work with.

For example, all apt commands have a simple syntax: apt commandname. And apt-get has additional commands, for example, apt-cache. Thus, when using apt, the user does not need to remember additional sets of commands.

In addition to simplifying work with commands, apt displays information more clearly, seemingly trifles, but it is more convenient to work with. For example, apt can show a progress bar, and when executed apt update you can see how many packages can be upgraded.

It is worth noting that the apt-get utility is more functional than apt. But for the average user, apt will be more than enough.

apt command

The syntax for the apt command is as follows:

sudo apt

Update package list

sudo apt update

APT has a list of repositories from which packages are installed. The list is stored in a text file /etc/apt/sources.list, as well as in the directory /etc/apt/sources.list.d/. When executing the command apt update, APT iterates through the list of repositories and from each repository in the list gets information about the packages in the repository. All this information is stored in the system.

If a new version of a package is released, APT will not know about it until the command is executed apt update. Therefore, if you install this package (without first running apt update), then the version of the package that is stored in the system at the moment will be installed.

Do I need to run apt update before installing every package?

No, before installing each package apt update of course it shouldn't be done. It is enough to run apt update periodically. If you have more than one package to install, you can first run apt update and then install the packages.

Update installed packages

To update the packages installed on the system, use the command:

sudo apt upgrade

This command only updates packages to new versions, never removes or installs other packages.

There is another command to update packages:

Sudo apt full-upgrade

This command updates packages, and removes or installs new packages as needed to resolve dependencies.

Install package

To install the package use the command:

sudo apt install

Install multiple packages

To install multiple packages, their names are separated by a space:

sudo apt install

Install a specific package version

To install a specific package version, you need to specify the required version after the package name, through the equal sign:

sudo apt install=

Delete a package

To remove an installed package, use the command:

Sudo apt remove

Remove a package and its configuration files

sudo apt purge

apt-purge works similarly apt-remove, but also removes configuration files related to the package. This means that if you installed some program, configured it, and then removed it with the command apt-remove, then the configuration file of this program will remain in the system. If you now install this program again, you will be able to use the previous configuration file, since it has not been removed.

apt-purge does not delete configuration files stored in your home directory.

If you removed the package with the command apt-remove, then you can do apt-purge for a given, already removed package, in order to “delete” its configuration files.

Remove unused packages

sudo apt autoremove

When you install a package, additional packages are often installed as dependencies. If you now remove this package, then the dependencies will remain in the system. apt autoremove removes those dependencies, but only those that other installed packages don't need.

Package List

The apt list command is used to list packages based on some criteria.

List the packages installed on the system:

Apt list --installed

List packages that need to be updated (that have a newer version):

apt list --upgradable

List all packages available for your system:

Apt list --all-versions

Search for packages

apt search

This command searches for the specified the words in the package name and in the package description. Regular expressions are supported.

You can only search by package names using the --names-only option:

Apt search --names-only

Searching for a package using regular expressions:

apt search --names-only "^python"

Package Information

apt show

Displays information about the package. The version, size, description, dependencies, and other information is displayed.

Editing the list of repositories

sudo apt edit-sources

Opens a file /etc/apt/sources.list in a text editor for editing, after saving the changes and closing the editor, checks the file for errors. If there are errors, displays a suggestion for re-editing the file in order to correct the errors.

Table of analogues of apt and apt-get commands

Team
apt
Command analogue
apt-get
Description
apt installapt-get installInstall package
apt-removeapt-get removeDelete a package
apt-purgeapt-get-purgeRemove package and config files
apt autoremoveapt-get autoremoveRemove unused packages
apt updateapt-get updateUpdate package list
apt upgradeapt-get upgradeUpdate packages
apt full-upgradeapt-get dist-upgradeUpdate packages (remove and install new ones if required)
apt listApproximate analogue:
dpkg-query --list
Package List
apt searchapt-cache searchPackage Search
apt showapt cache showPackage Information