apt install f does what. APT package management system

Sometimes there are situations when you need to find out which packages are installed on the system. This may be necessary if you want to backup installed packages, check their integrity, transfer all packages to another system and for many other tasks. On Debian, several methods can be used for this.

In today's article, we'll look at how to list installed Debian packages using the terminal, the curses interface, and also the GUI. Such lists can be used not only for Reserve copy, but also to just iterate over and remove unnecessary programs, thereby clearing the system of debris.

The very first way to view installed Debian packages is with the dpkg utility. It can be used not only in Debian, but in all distributions based on it:

dpkg --get-selections | grep -v deinstall

dpkg --get-selections | grep -v deinstall > mylist.txt

You can also remove all unnecessary information and keep only the package names:

dpkg -l | grep ^ii | awk "(print $2)" > mylist.txt

The next way to accomplish this task is to use the dpkg-query utility. It is similar to the previous version, but a little simpler. This command will list all installed packages along with information about them:

Here, too, you can only select package names with the -f option:

dpkg-query -f "$(binary:Package)\n" -W

The third method is the apt utility we are used to using to install applications, it has a list command:

apt list --installed

apt list --installed | grep python

We covered apt in more detail in the article. Another interesting feature of apt is to see which packages have been manually installed. To do this, type:

apt-mark showmanual

And another option using apt:

apt-cache pkgnames

The aptitude package management tool also allows you to list installed packages:

aptitude search "~i!~M"

Also, aptitude can run in curses mode, which is very convenient:

The last way to see the list of installed packages is in the /var/lib/apt/extended_states file. This is a database that contains installed programs debian in this format:

Package: package_name
Architecture: architecture
Auto-Installed: 0_or_1

cat /var/lib/apt/extended_states

Restoring the List of Installed Packages

Many users create a list of packages not just to look at, but for future recovery. If you made a list using dpkg, then it can be very easily restored to the system using a similar command:

sudo dpkg --clear-selections
$ sudo dpkg --set-selections< mylist.txt

Everything is very simple. To install packages after adding them to the list, use the command:

sudo apt dselect-upgrade

If you just have a list of package names, then you need to restore it a little differently. Just pass all these names to the apt command to install:

xargs< mylist.txt apt install -y

conclusions

In this article, we looked at how to list installed Debian packages. This can be very useful and is quite easy to do. I hope this information was helpful to you.

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 it becomes necessary to reinstall the package (file corruption, more new version), it can be done with 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.

The apt-get utility is a powerful free console program used and working with the APT (Advanced Packaging Tool) library to install new software packages, remove existing ones, upgrade installed ones, and upgrade the entire operating system.

The apt-cache console utility is used to search the cache for APT software packages. talking in simple terms, this tool is used to search for packages, gather information about packages, and find packages available for installation in operating systems based on Debian or Ubuntu.

How can I get a list of all available packages?

To see all available packages, run the following command:

apt-cache pkgnames

How can I find the package name and description.

To find the package name and description before installing, use the "search" flag. Using "search" with apt-cache will display a list of matching packages with brief description. For example, if you want to find the description of the vsftpd package: to do this, the command would be:

apt-cache search vsftpd

To find and list all packages whose name starts with vsftpd , you can use the following command:

apt-cache pkgnames vsftpd

How can I view package information?

For example, if you want to see information about a package, with a short description showing the version number, checksums, size, size after installation, categories, and so on, you can use the "show" subcommand, as shown below:

apt-cache show netcat

How can I check the dependencies of a package?

To check the dependencies of a particular package, you can use the showpkg subcommand to see if those dependencies are installed or not. For example, use the showpkg command along with the package name.

apt-cache showpkg vsftpd

How can I view cache statistics?

The stats subcommand will display full statistics about the cache, such as the total number of packages found in the cache. Use this command:

apt-cache stats

How to update the list of packages in the system?

The update command is used to synchronize and update package index files. Synchronization occurs with the sources specified in the file /etc/apt/sources.list. This command can be used, for example, to keep track of important package updates.

Sudo apt-get update

How to update packages in the system?

The upgrade command is used to upgrade all currently installed software on your system. Sometimes it may happen that an update cannot be installed due to some other package that requires an older version.

sudo apt-get upgrade

But if you want to upgrade regardless of package requirements, use the dist-upgrade subcommand:

sudo apt-get dist-upgrade

How can I install or update any particular package?

The install subcommand is used to install or upgrade a package.

sudo apt-get install netcat

How can I install multiple packages at once?

You can enter the names of several packages to install them at the same time. For example, to install the nethogs and goaccess packages, you can run the following command:

sudo apt-get install nethogs goaccess

How to install multiple packages by "mask" name

With regular expressions, you can add multiple packages using special characters. For example, you can use an asterisk to install all packages that contain the string "name" in their name:

sudo apt-get install *name*

How to install packages without updating.

Using the --no-upgrade flag will prevent packages that are already installed from being upgraded.

sudo apt-get install packageName --no-upgrade

How to only update certain packages?

The --only-upgrade flag will not install new packages, it will only upgrade existing ones.

sudo apt-get install packagename --only-upgrade

How can I install a specific version of a package?

Let's imagine that you need to install a specific version of a package, just use an equal sign along with the package name and attribute the desired version.

sudo apt-get install vsftpd=2.3.5-3ubuntu1

How to remove packages without deleting settings?

To remove software packages without removing their configuration files (for later use), use the remove command as shown.

sudo apt-get remove vsftpd

How to completely remove packages?

To remove a package along with its configuration files, use the purge subcommand as shown below.

sudo apt-get purge vsftpd

Or you can combine both commands, like this:

sudo apt-get remove --purge vsftpd

How can I clear disk space?

The clean command is used to free up disk space by removing the resulting package .deb files in your local repository.

sudo apt-get clean

As soon as download source package?

To only download the source code of a package, you can use the --download-only source option with the package name, like this:

sudo apt-get --download-only source vsftpd

How can I download and unpack a package?

To download and unpack the source code of a package into a special directory, run the following command:

sudo apt-get source vsftpd

How can I download, unpack and compile the source code of a package?

You can also download, unpack and compile the package source using the '--compile' option, as shown below:

sudo apt-get --compile source goaccess

How to download a package without installation

Using the "download" option, you can download any package without installing it. For example, the following command will only download the nethogs package to the current working directory.

sudo apt-get download nethogs

How can I view the changelog of a package?

The changelog flag downloads the package's changelog and displays the version of the package, if installed.

sudo apt-get changelog vsftpd

How can broken dependencies be fixed?

The "check" command is a diagnostic tool, it is used to update the package cache and check for broken dependencies.

Sudo apt-get check

How can I find and build dependencies?

The build-dep command looks for and installs the built dependencies of the required package. If the package is not in the local repository, you will get an error.

sudo apt-get build-dep netcat

How can I automatically clear the Apt-Get cache?

The autoclean command removes all .deb files from /var/cache/apt/archives to free up space on your hard drive.

sudo apt-get autoclean

How can I automatically remove unnecessary packages?

The autoremove subcommand is used to automatically remove packages that were installed as dependencies of others but are no longer needed. For example, the following command will remove an installed package along with its dependencies.

sudo apt-get autoremove vsftpd

Information courtesy of the site. Thank you.

Advanced Packaging Tool- a set of utilities for managing software packages in operating systems based on Debian. APT provides a friendly add-on to DPKG and allows you to:

    Install, remove and upgrade packages

    Solve dependencies

    Search for packages by specified criteria

    View package details

    Manipulate keys from repositories

APT is one of basic programs and included with Ubuntu.

Settings

All APT configuration files are stored in the directory /etc/apt.

apt.conf

/etc/apt/apt.conf is the main configuration file used by all APT tools. A description of all possible settings and options can be found in the documentation for it:

manapt.conf

apt.conf.d

Directory containing configuration files similar in syntax. Using this directory, you can quickly and conveniently manipulate APT settings by adding or removing prepared files with settings.

auth.conf

sources.list

sources.list.d

Directory with repository files, by appointment similar to sources.list. Each repository is described in a separate file.

Usage

APT includes several utilities that perform separate tasks.

Starting with Ubuntu 16.04, a new apt utility is available that contains the most commonly used commands from apt-get and apt-cache . The apt utility is intended for users, while apt-get can be considered as a lower level tool.

apt-get

apt-get it is a package management utility. apt-get requires superuser rights to work.

Basic commands:

    Update - Update information about the packages contained in the repositories.

    Install foo - Install package foo. Downloading, installation and configuration occur automatically. If more information is needed to configure package foo, a prompt will be shown to the user.

    Upgrade - Upgrade packages for which new versions are available in the repository.

    Dist-upgrade - Upgrade packages that require dependency resolution (install additional or remove conflicting packages).

    Remove foo - Remove package foo from the system.

    Purge foo - Remove package foo and purge the system of its configuration files. Settings files in user home directories will not be deleted.

    Autoremove - Remove a package that is no longer needed in the system. Used to clean the system of unnecessary packages. The fact that a package is no longer needed is defined as follows: if a package was not installed on its own, but as a dependency of another package that was subsequently removed, then that package is also no longer needed in the system.

    Source foo - Getting source code package foo.

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 name
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 update installation 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 use 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

mob_info