Apt-get. Package management in Ubuntu


APT (Advanced Packaging Tool) is a utility in Debian-like systems that installs, updates packages, and tracks their dependencies. The purpose of creating the program was to automate the package management process, in particular updating and maintaining dependencies, which in the case of direct work with the dpkg manager occurred manually. Direct manipulation of packages is performed using the program apt-get, basic commands for working with which will be discussed below.

General apt-get command structure

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

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

Updating the list of packages available for installation

Performed this action using the command:

Apt-get update

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

Installing the package

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 dependencies. If there are dependencies, a list of them and an installation suggestion will be displayed.

Root@vps:~# 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 occur automatically without prompting any questions.

Also, when entering the command to install packages, you can specify the names of the packages that need to be removed. To do this, you must add a hyphen at the end of the name of the package to be removed. An example of this installation/removal method is given below:

Root@vps:~# 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, and the htop package is prepared for removal.

Reinstalling a package

If there is a need to reinstall the package (file damage, newer version appears), 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 configuration files (if any).

Usually this option may be required if you plan to reinstall this package in the future. This method of removal is performed with 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 package removal

Unlike the first method, all files that are related to the package being deleted, including configuration files, will be deleted. 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 names.

  • Uninstall and install in one command

In addition, when uninstalling, you can select a list of packages to install. To do this, you must specify “ + ” at the end of the package name. An example of such a command is given below:

Root@vps:~# 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 allow you to update information about available packages and their versions. After executing this command, you can proceed directly to updating installed packages on the system. This is done with the command:

Apt-get -u upgrade

Specified parameter -u used to get full list packages that will be prepared for the update.

Updating the distribution version

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

Due to the fact that some comrades do not understand what apt and dpkg are. I decided to create another post about these utilities.

APT and everything, everything, everything. Exploring the capabilities of the APT package manager and related programs

Debian brought a lot of positive innovations to the Linux world, many of which were adopted by other distributions. The most significant improvement to Debian was the APT package management system; after its release, all other distributions turned into outdated trash. Today, APT is complex, smart, flexible and hides many secrets from the uninitiated Linux user.

Advanced package management system

APT (Advanced Packaging Tool) itself is not a package management system in the truest sense of the word. All actions for unpacking, registering in the system and viewing the package database are performed by the dpkg package utilities, while the APT utilities are a wrapper that is used to search for packages, check checksums, download from the repository, resolve dependencies, as well as a number of other actions .

APT includes the following set of utilities:

apt package utilities

apt-cache - manipulates the cache of available packages, commonly used
to search for a package and/or get information about it

apt-cdrom - allows you to add a CD/DVD as a package source (repository)

apt-config - reads the values ​​of options specified in the configuration
file /etc/apt/apt.conf, used by other APT utilities

apt-extracttemplates - extracts DebConf configuration files
from packages, used by other APT utilities

apt-ftparchive - creates index files

apt-get - installs, removes, updates package list
and the packages themselves, the central APT utility

apt-key - manages authentication keys used for verification
authenticity of package sources

apt-secure - checks authenticity digital signature apt packages included
included in the distribution and repositories

apt-sortpkgs - sorts index files

The utilities rely on the following configuration files:

APT configuration files

/etc/apt/sources.list - list of package sources (repositories)
/etc/apt/apt.conf - main APT configuration file
/etc/apt/preferences - preference file, controls which version of the package will be
installed if there are several versions in the repository at once

APT is simple and straightforward to use; the average user usually only needs the six commands below:

Basic APT Commands

apt-cache search mask - package search
apt-cache show package - view package information
apt-get install package - installing a package
apt-get remove package - remove a package
apt-get update - update the cache of available packages
apt-get upgrade - update all packages

The last two commands are usually run one after the other, which will reinstall all packages for which new versions are available in the repository. If you need to update only the specified package, then after “apt-get update” you should run the command “apt-get install package”.

The Ubuntu distribution makes the process of “communicating” with APT utilities even simpler and reduces it to clicking on the checkboxes of the graphical interface. It has its own, extremely simple, package manager (that’s called “Package Manager”), launched via cron. Updates Manager, a graphical installer for manually downloaded GDebi deb packages and a more powerful graphical add-on for Synaptic APT utilities.

Meanwhile, APT is much more complex and flexible than it might seem at first glance. Therefore, in the following sections we will look at several not entirely typical methods of using it.

Third Party Package Sources

In addition to the main repository, which contains all the packages from the distribution's developers, there are a lot of other package sources that may contain third-party software that is not available from the official repository, provide more recent versions of it, or simply be a faster mirror. The repository can be either a regular directory on your hard drive or a CD.

To teach APT to work with third-party repositories, just follow four simple steps:

The uri field is the repository address, which in most cases is an HTTP address, but can also be a link to a local repository (file:/root/repository), the address of a repository on an FTP or SSH server. The "distribution" field indicates the name of the distribution for which the packages are collected. For Debian, the name can be one of stable, oldstable, unstable, testing, while in the case of Ubuntu, you should only indicate the specific name of the distribution (for example, jaunty), as well as various designations based on it (for example, jaunty-updates, jaunty- backports, jaunty-security). It must be said that APT is not at all against mixing packages from different distributions on one system, but in this case only you will be responsible for the consequences. The component is usually named main, contrib or non-free for Debian and main, universe, multiverse, partner and restricted for Ubuntu. These are all names of different package repositories, which are separated only to separate packages based on some criteria. For example, main are packages collected by a group of Ubuntu/Debian developers; there are certain guarantees for the quality of the software contained in them, including timely updates and bugfixes, while contrib and universe are third-party software that you install at your own risk. risk.

2. Add to apt keyring the public key of the repository, used to verify its authenticity and reliability. The key can be obtained by any means and added by running the command “apt-key add key”, but this method is rarely practiced due to its inconvenience. In the vast majority of cases you will be dealing with a team

sudo apt-key adv --keyserver certificate-server --recv-keys key-id
which requests the key directly from the certification server (for Ubuntu this is keyserver.ubuntu.com). This is how most third-party developers distribute their software for Debian/Ubuntu distributions (while others simply post packages and their checksums). For example, by going to the page of the project you are interested in on launchpad.net hosting and clicking on the link “Technical details about this PPA”, you will see a line that needs to be added to /etc/apt/sources.list, in “Signing key:” will be indicated Key ID.

3. Update the cache of available packages:

sudo apt-get update
4. Install the package using the command “apt-get install package”.

Many developers put a link to the repository and its key ID directly in the deb package, so after downloading the package, installing it and running the command “apt-get update && apt-get upgrade” the packages will be updated along with their brothers listed in the sources.list. In particular, this is how Opera browsers and the alpha release of Google Chrome are distributed.

A repository located on a CD is much easier to add to sources.list. There is a special command for this, apt-cdrom. You simply insert the CD into the drive and run the command:

sudo apt-cdrom add

Tricks and unusual situations

APT is APT, it is convenient and simple, but sometimes you cannot do without tricks, the most useful of which you will learn from this section.

1. By default, the "apt-get remove" command removes a package completely only if none of its files have been modified since installation, otherwise the modified files remain untouched. Naturally, configuration files almost always change, so apt-get leaves behind a bunch of garbage that you have to clean up manually. The command "apt-get purge" instead of "apt-get remove" solves this problem.

2. Those who like to tinker with the system, as well as system administrators whose servers have been hacked, will most likely want to return the packages to the initial state in which they were before the manipulation. The command will help with this:

sudo apt-get install --reinstall package
3. Lower-level deb package management utilities (such as dselect and dpkg) maintain a special list of package states that can be used to control which packages should be installed or removed in batch mode (this is how dselect + dpkg works). It can also be used for many other purposes, for example, to transfer the system configuration to another machine. Run the following command:

dpkg --get-selections > file
Transfer the file to another machine and run two commands on it:

cat file > dpkg --set-selections
apt-get dselect-upgrade

All packages of the source system will be added to the system. To make the package state file also contain information about which packages should be removed from the system, add a "\*" character after the "--get-selections" argument. The status list does not contain package versions; this can be used after installing a newer version of the distribution to bring it to the required state.

4. You manually applied a patch to a file of one of the system packages and do not want this package to be updated (with the destruction of all your changes) after calling “apt-get upgrade”. In this case, the list of states will again come to your aid. The package may be frozen, causing apt-get to refuse to update it and skip it:

echo -e "coreutils hold" | dpkg --set-selections
You can force a package update by specifying the "-u" flag when calling apt-get.

5. Like any system with network functionality, APT allows you to use a proxy to access repositories. To enable this feature, add the following line to the /etc/apt/apt.conf file:

Acquire::http::Proxy "http://xxx.xxx.xx:yyyy"

Where xxx.xxx.xx is the name of your proxy, yyyy is the port.

6. Typically, APT utilities request the newest version of a package from all that are in its cache, so if you added various experimental and unstable repositories to sources.list, then after updating you will receive a distribution consisting exclusively of experimental or unstable packages, and a bunch of problems caused by this state of affairs. However, the situation can be easily resolved by placing the following line in /etc/apt/apt.conf:

APT::Default-Release "release";

Where release is oldstable, stable, unstable, testing or experimental for Debian or the release name for Ubuntu. Now, if you need to install a package from the specified distribution, just write its name after the "-t" argument when calling apt-get:

sudo apt-get -t unstable install package
7. All received apt-get deb packages are stored in the /var/cache/apt/archives directory, which means that if you reinstall the system, you can copy the contents of the directory to another disk/partition, and then restore it and save time/ package installation traffic. Besides, this is essentially a snapshot of your installed system(that part of it that you installed yourself), which can be attributed to a friend (together with the list of states described in the third paragraph) or, if not needed, deleted to free up space.

8. The deleted system snapshot described in the previous paragraph can be easily restored using the design below:

sudo dpkg --get-selections | grep -v "deinstall" | \
awk "(print $1)" | xargs dpkg-repack

9. In addition to binary packages, the Debian/Ubuntu repositories also contain application source packages that can be obtained and built using the following command:

sudo apt-get -b source packagename

Third party utilities

The APT system has come a long way, so in addition to the official utilities included in the apt package, the Debian and Ubuntu repositories are replete with third party utilities, which can be used to perform some non-standard tasks.
The most useful of them is called apt-file and is necessary, as you might guess from the name, to determine whether a particular file belongs to a specific package. Install:

sudo apt-get install apt-file
We ask apt-file to create a cache of all files installed in the package system (it will be searched):

apt-file search /usr/bin/apt-get
apt: /usr/bin/apt-get

We request a list of all package files:

apt-file list apt

A simple utility called apt-show-versions will show you which packages can be upgraded, including versions and other details. Run it with the "-u" flag to get a list of only the packages to be updated (instead of a list of all packages).

If you installed a large number of various packages and now you want to get rid of unnecessary trash, then the deborphan utility will help in this matter, which searches for unused packages and orphaned dependencies. Just run deborphan without any arguments, and you will see a list of packages, which you can immediately pass as input to the “apt-get remove” command, or simply run the following command:

sudo apt-get remove `deborphan`

By default, deborphan only processes packages containing libraries, but this behavior can be changed by adding the "-a" flag to the command invocation:

You should not immediately rush to remove the packages shown by the utility, because even the most powerful heuristic algorithm is not able to determine your personal needs. So, the program showed me the packages google-chrome, inkscape and even xorg.

The apt-move utility will allow you to create a local repository. Install the program, open the /etc/apt-move.conf file, specify in the LOCALDIR option the path to the directory in which the repository should be located, and run the command:

sudo apt-move update

As a result, all packages downloaded from the Internet using apt-get (directory /var/cache/apt/archives) will be moved to the directory specified in the config, for which an index file will be created. This convenient way creating an intranet repository for those cases when a lot of identical packages need to be installed on many machines.

To create a local repository, it is also very convenient to use the apt-proxy server, which allows you to cache deb packages downloaded from the repository on the server side. To do this, apt-proxy is installed on a dedicated machine (possibly a gateway), and the sources.list of clients is modified so that the address of this machine is specified as the uri field of all repositories. As a result, all requests for deb packages are redirected to apt-proxy, which requests the package from the head repository and stores it in its cache, and the response to all subsequent requests for this package will be returned from the cache.

First, install apt-proxy on a dedicated machine:

sudo apt-get install apt-proxy

Next, open the file /etc/apt-proxy/apt-proxy-v2.conf, go to the section and replace the value of the address option with the IP address of the machine, and also describe the packet sources used by apt-proxy, for example:

sudo vi /etc/apt-proxy/apt-proxy-v2.conf


backends = http://ru.archive.ubuntu.com/ubuntu/
min_refresh_delay = 1d


backends = http://security.ubuntu.com/ubuntu/
min_refresh_delay = 1d

Usually these two addresses are enough to cover the entire range of packages provided by Ubuntu developers. Restart apt-proxy:

sudo invoke-rc.d apt-proxy restart

To switch clients to using apt-proxy, take the standard Ubuntu sources.list, replace all real uri fields with “http://IP-address-apt-proxy:9999/ubuntu/” and copy this file to each client.

There are many other, less interesting utilities that work in conjunction with APT. For example, apt-dater allows you to update packages on a large number of remote nodes using a pseudo-graphical interface. The aptsh program implements a sh-like command interface on top of the apt package commands, aptfs is a virtual file system for managing APT. The debdelta utility, which allows you to update packages by downloading their deltas from the Internet, could be the topic of a separate article if there were at least one timely updated repository for it.

Aptitude

The apt-get utility and its relatives are not the only APT implementation available. An even more powerful, convenient and versatile alternative to them is called aptitude and is a concentrated functionality of apt-get, apt-cache and dselect in one place.
Aptitude allows you to install/uninstall, search, update, and do a lot of other things with packages using two types of interface: command mode, similar to apt-get and apt-cache, and a mode with a pseudo-graphical interface, externally reminiscent of the dselect interface, but much more convenient and functional.

In command line mode, aptitude can be used to do things like:

aptitude install - package installation

aptitude remove - remove package and orphaned dependencies

aptitude purge - remove package, orphaned dependencies
and the remaining configuration files after them

aptitude search - search for a package in the cache (list of available packages)

aptitude update - cache update

aptitude safe-upgrade - update packages

aptitude clean - remove previously downloaded packages

aptitude full-upgrade - update packages,
even if this action requires removing any packages

aptitude show - package information

aptitude autoclean - remove outdated packages

aptitude hold - setting a ban on updating a package

The interactive mode, available when running aptitude without arguments, allows you to perform all the same actions using a pseudo-graphical interface built on the ncurses library. It works in batch mode (select packages - start the installation process), so it will be convenient in cases where you need to install a large number of packages.

Easter eggs

The developers of the APT utilities turned out to be guys with a somewhat twisted sense of humor. Just look at the result of the following command:

sudo apt-get moo
What looks even wilder is what the creators of aptitude built into their program. Try:

sudo aptitude moo
A sort of Easter egg without easter egg. OK:

sudo aptitude -v moo
sudo aptitude -vv moo
sudo aptitude -vvv moo
sudo aptitude -vvvv moo
sudo aptitude -vvvvv moo

And the final chord:

sudo aptitude -vvvvvv moo

Useful apt-cache commands

apt-cache show package - detailed information about the package
apt-cache showpkg package - general information about the package
apt-cache depends package - list of package dependencies
apt-cache rdepends package - list of reverse dependencies (who needs the specified package)

APT Dictionary

Package - a program, library, source code or any other files, as well as their metadata, packaged in a specially formed archive.

Repository is a storage place for deb packages.

Available package cache (or simply cache) is a file that caches information about all packages available from the sources listed in /etc/apt/sources.list. The cache is updated every time the "apt-get update" command is called.

Index file - the head file of the repository containing the name, version, size, short and Full description and dependencies for each package. It is named Packages.gz in the case of a binary repository and Sources.gz for a source code repository. Created using the pkg-scanpackages and dpkg-scansources utilities.

Apt keyring (literally: apt key ring) is a repository of keys that authenticate package sources (repositories).

What is inside?

The hallmark of Deb packages is their simplicity. Any Deb package consists of three files: data.tar.gz, control.tar.gz and debian-binary, packed with the ar archiver. The file data.tar.gz is the contents of the package (binaries, man's, documentation, etc.), control.tar.gz is metadata, in the simplest version two files: control, containing a description of the package, dependencies, size, etc. .d., and md5sums are checksums of all package files. The debian-binary file contains the format version of the Deb package (for example, 2.0). To unpack the package, you can use the command:

ar -xv package.deb && tar -xzf data.tar.gz

Advanced Packaging Tool is a high-level tool for working with packages.

Working with packages using dpkg.

dpkg is the main program on the system for working with Debian packages. If there are .deb packages, it is dpkg that allows you to install them or analyze their contents. However, this program has only a partial view of the Debian world: it knows what is installed on the system, as well as everything passed to it on the command line, but it knows nothing about other available packages. Therefore, it will fail if it encounters an unsatisfied dependency. Tools like apt, on the other hand, will automatically create a list of dependencies so that everything can be installed as automatically as possible.

dpkg or apt?

dpkg should be considered as a low-level tool (engine), and apt as a tool closer to the user, bypassing the limitations of the first. These tools work together, each with its own specifics, tailored for a specific range of tasks.

Installing packages

dpkg is primarily a tool for installing already available Debian packages (since it doesn't download anything). To install a package, use the -i or --install option.

Installing a package using dpkg

Dpkg -i man-db_2.7.0.2-5_amd64.deb




The man-db package (2.7.0.2-5) is being configured...

We can see every step dpkg executes, so we know where any error might have occurred. The installation can also be done in two stages: first unpacking, then configuration. This makes apt-get make fewer calls to dpkg (each such request is an expensive operation due to the need to load the database into memory, including the entire list of already installed files).

Separate unpacking and setup

Dpkg --unpack man-db_2.7.0.2-5_amd64.deb

(Reading database... on this moment 86425 files and directories installed.)
Preparing to unpack man-db_2.7.0.2-5_amd64.deb ...
Man-db (2.7.0.2-5) is unpacked to replace (2.7.0.2-5) ...
Triggers for mime-support (3.58) are processed...

Dpkg --configure man-db

The man-db package (2.7.0.2-5) is being configured...
Updating database of manual pages ...

Sometimes dpkg, for one reason or another, cannot install a package and returns an error; if the user instructs to ignore this error, only a warning will be issued; There are various --force-* options for this. The dpkg --force-help command, or its documentation, will give a complete list of such options. The most common error that you will sooner or later encounter is a file conflict. When a package contains a file that is already installed by another package, dpkg will refuse to install it and we will receive a message like this:

The libgdm package is unpacked (from the file.../libgdm_3.8.3-2_amd64.deb) ...
dpkg: error processing the parameter /var/cache/apt/archives/libgdm_3.8.3-2_amd64.deb (--unpack):
trying to overwrite "/usr/bin/gdmflexiserver" which is already in package gdm3 3.4.1-9

In this case, if you believe that replacing this file does not pose a significant risk to the stability of your system (this is often the case), you can use the --force-overwrite option, which will tell dpkg to ignore this error and overwrite the file.
Although there are many --force-* options, only --force-overwrite is recommended for regular use. The rest are intended only for exceptional cases, and it is better to leave them alone as long as possible in order to comply with the rules laid down when the package was created. Do not forget that these rules are a guarantee of the integrity and stability of the system.

ATTENTION! Effective use--force-*

If you're not careful, using the --force-* option can cause APT commands to stop working. Some of these options allow you to install a package with unmet dependencies or if there is a conflict. As a result, the consistency of the system in terms of dependencies is broken, and APT commands will refuse to do anything other than that which will return the system to a consistent state (this usually amounts to installing the missing dependency or removing the problematic package). Here is an example of a message indicating such an error, which was received after installing a new version of rdesktop and ignoring the dependency on a newer version of libc6:

apt full-upgrade

You may want to use "apt-get -f install" to fix these errors.
Packages with unmet dependencies:
rdesktop: Depends on: libc6 (>= 2.5) but 2.3.6.ds1-13etch7 is already installed
E: Unmet dependencies.

Try using -f.
Intrepid administrators who are confident in their analysis of the situation can ignore the warning about a dependency problem or conflict by using the appropriate --force-* option. In this case, if you want to continue using apt or aptitude, you need to edit /var/lib/dpkg/status and remove/change the dependency or conflict.
Editing this file is a dirty hack and should not be used except in extreme cases. Often the best solution is to rebuild the offending package ("Rebuild the package from its source") or use a new version of it (probably fixed) from a repository such as stable-backports (see Section 6.1.2.4, "Stable Software with Backports Compatibility" ).

Removing a package

Running dpkg with the -r or --remove option followed by the package name will remove that package. This removal, however, is not complete: all configuration files, maintainer scripts, log files (system logs) and other user data used by this package will remain. In this way, it is easy to get rid of the program by uninstalling it, but at the same time it remains possible to install it again with the same configuration. To completely remove everything associated with a package, use the -P or --purge option followed by the package name.

Complete removal of the debian-cd package

Dpkg -r debian-cd

(Reading the database...there are currently 97747 files and directories installed.)

Dpkg -P debian-cd

(Reading the database...there are currently 97401 files and directories installed.)
The debian-cd package (3.1.17) is being removed...
The configuration files of the debian-cd package (3.1.17) are cleared...

dpkg database queries and parsing .deb files

For most options, there are "long" options (one or more words preceded by a double hyphen) and "short" options (a single letter, often the first letter of the "long" option, followed by a single hyphen). This convention is so common that it is already a POSIX standard.
Before finishing this section, let's look at dpkg's options for querying the internal database to get various information. In this case, the long options will be specified first, and then the corresponding short options (which, of course, take the same arguments). Thus, --listfiles package (or -L) lists the files installed by the package; --search file (or -S) searches for the package this file belongs to; --status package (or -s) displays information about a particular installed package; --list (or -l) shows a list of packages known to the system and their status; --contents file.deb (or -c) shows a list of files in this package; --info file.deb (or -I) shows Debian package information.

Retrieving information using dpkg

Dpkg -L base-passwd

/.
/usr
/usr/sbin
/usr/sbin/update-passwd
/usr/share
/usr/share/man
/usr/share/man/ru
/usr/share/man/ru/man8
/usr/share/man/ru/man8/update-passwd.8.gz
/usr/share/man/pl
/usr/share/man/pl/man8
/usr/share/man/pl/man8/update-passwd.8.gz
/usr/share/man/man8
/usr/share/man/man8/update-passwd.8.gz
/usr/share/man/fr
/usr/share/man/fr/man8
/usr/share/man/fr/man8/update-passwd.8.gz
/usr/share/doc-base
/usr/share/doc-base/users-and-groups
/usr/share/base-passwd
/usr/share/base-passwd/passwd.master
/usr/share/base-passwd/group.master
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/base-passwd
/usr/share/doc
/usr/share/doc/base-passwd
/usr/share/doc/base-passwd/copyright
/usr/share/doc/base-passwd/users-and-groups.html
/usr/share/doc/base-passwd/changelog.gz
/usr/share/doc/base-passwd/users-and-groups.txt.gz
/usr/share/doc/base-passwd/README

Dpkg -S /bin/date

coreutils: /bin/date

Dpkg -s coreutils

Package: coreutils
Essential: yes
Status: install ok installed
Priority: required
Section: utilities
Installed-Size: 13822
Maintainer: Michael Stone
Architecture: amd64
Multi-Arch: foreign
Version: 8.13-3.5
Replacements: mktemp, timeout
Depends: dpkg (>= 1.15.4) | install-info
Pre-Depends: libacl1 (>= 2.2.51-8), libattr1 (>= 1:2.4.46-8), libc6 (>= 2.7), libselinux1 (>= 1.32)
Conflicts: timeout
Description: GNU core utilities
This package contains the basic file, shell and text manipulation
utilities which are expected to exist on every operating system.
.
Specifically, this package includes:
arch base64 basename cat chcon chgrp chmod chown chroot cksum comm cp
csplit cut date dd df dir dircolors dirname du echo env expand expr
factor false flock fmt fold groups head hostid id install join link ln
logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup nproc od
paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir runcon
sha*sum seq shred sleep sort split stat stty sum sync tac tail tee test
timeout touch tr true truncate tsort tty uname unexpand uniq unlink
users vdir wc who whoami yes
Homepage: http://gnu.org/software/coreutils

Dpkg -l "b*"

Desired=unknown[u]/install[i]/delete[r]/clear[p]/commit[h]
| Status=not[n]/installed[i]/configured[c]/unpacked[U]/partially configured[F]/
partially installed[H]/trig-aWait/Trig-pend
|/ Error?=(none)/reinstallation required[R] (upper case
in the status and error fields indicates an abnormal situation)
||/ Name Version Architecture Description
+++-============-==============-==============-================================
un backupninja<нет>(description not available)
un base<нет>(description not available)
un base-config<нет>(description not available)
ii base-files 7.1 amd64 Debian base system miscellaneous
ii base-passwd 3.5.26 amd64 Debian base system master passwo
[...]

Dpkg -c /var/cache/apt/archives/gnupg_1.4.12-7_amd64.deb

drwxr-xr-x root/root 0 2013-01-02 19:28 ./
drwxr-xr-x root/root 0 2013-01-02 19:28 ./usr/
drwxr-xr-x root/root 0 2013-01-02 19:28 ./usr/share/
drwxr-xr-x root/root 0 2013-01-02 19:28 ./usr/share/doc/
drwxr-xr-x root/root 0 2013-01-02 19:28 ./usr/share/doc/gnupg/
-rw-r--r-- root/root 3258 2012-01-20 10:51 ./usr/share/doc/gnupg/TODO
-rw-r--r-- root/root 308 2011-12-02 18:34 ./usr/share/doc/gnupg/FAQ
-rw-r--r-- root/root 3543 2012-02-20 18:41 ./usr/share/doc/gnupg/Upgrading_From_PGP.txt
-rw-r--r-- root/root 690 2012-02-20 18:41 ./usr/share/doc/gnupg/README.Debian
-rw-r--r-- root/root 1418 2012-02-20 18:41 ./usr/share/doc/gnupg/TODO.Debian
[...]

Dpkg -I /var/cache/apt/archives/gnupg_1.4.12-7_amd64.deb

new debian package, version 2.0.
size 1952176 byte(s): control archive length 3312 byte(s).
1449 byte(s), 30 control lines
4521 byte(s), 65 lines md5sums
479 byte(s), 13 lines * postinst #!/bin/sh
473 byte(s), 13 lines * preinst #!/bin/sh
Package: gnupg
Version: 1.4.12-7
Architecture: amd64
Maintainer: Debian GnuPG-Maintainers
Installed-Size: 4627
Depends: libbz2-1.0, libc6 (>= 2.4), libreadline6 (>= 6.0), libusb-0.1-4 (>= 2:0.1.12), zlib1g (>= 1:1.1.4), dpkg (>= 1.15.4) | install-info, gpgv
Recommends: libldap-2.4-2 (>= 2.4.7), gnupg-curl
Suggests: gnupg-doc, xloadimage | imagemagick | eog, libpcsclite1
Section: utilities
Priority: important
Multi-Arch: foreign
Homepage: http://www.gnupg.org
Description: GNU privacy guard - a free PGP replacement
GnuPG is GNU"s tool for secure communication and data storage.
It can be used to encrypt data and to create digital signatures.
It includes an advanced key management facility and is compliant
with the proposed OpenPGP Internet standard as described in RFC 4880.
[...]

LETTING DEPTH: Version Comparison

Since dpkg is a Debian package management program, it also contains a reference implementation of the version number comparison logic. That's why it has the --compare-versions option used external programs(mainly by setup scripts run by dpkg itself). This option requires three parameters: a version number, a comparison operator, and a second version number. Valid comparison operators are lt (strictly less than), le (less than or equal to), eq (equal to), ne (not equal to), ge (greater than or equal to), and gt (strictly greater than). If the comparison is correct, dpkg returns 0 (success); if not, then a non-zero value (an error).

$ dpkg --compare-versions 1.2-3 gt 1.1-4
$echo$?
0
$ dpkg --compare-versions 1.2-3 lt 1.1-4
$echo$?
1
$ dpkg --compare-versions 2.6.0pre3-1 lt 2.6.0-1
$echo$?
1

Note the unexpected failure of the last comparison: for dpkg, the letters pre, which typically denote pre-release, have no special meaning, and alphabetic characters are compared in the same way as numbers (a< b < c ...), в алфавитном порядке. Именно поэтому dpkg считает, что «0pre3» больше, чем «0». При необходимости указать в номере версии, что она относится к предварительному выпуску, используется символ тильды «~»:

$ dpkg --compare-versions 2.6.0~pre3-1 lt 2.6.0-1
$echo$?
0

dpkg log file

dpkg keeps a log of all its actions in /var/log/dpkg.log. This log is extremely detailed, documenting every step of the way dpkg packages are processed. This log helps not only to track the behavior of dpkg, but also to maintain a history of changes in the system: the exact moment when each package was installed or updated can be found, and this information can be extremely useful in determining the reasons for the change in the behavior of the system as a whole. In addition, information about all versions is recorded and can be easily checked against the changelog.Debian.gz from the corresponding package or against online bug reports.

Multi-architecture support

All Debian packages have an Architecture field in their metadata. This field can contain either the value "all" (for packages that are architecture independent) or the name of the specific architecture for which the package is intended (for example, "amd64", "armhf", ...). In the latter case, dpkg will by default only allow a package to be installed if its architecture matches the system architecture returned by dpkg --print-architecture.
This restriction ensures that there are no binaries compiled for the wrong architecture on the system. That would be fine, but (some) computers can run binaries for different architectures, either natively (for example, "amd64" systems run binaries for "i386") or through emulators.

Enabling multi-architecture

dpkg's multi-architecture support allows you to define "foreign architectures" that can be installed on a given system. This is easy to do with dpkg --add-architecture, as shown in the example below. There is also a corresponding dpkg --remove-architecture command to disable support for a foreign architecture, but it can only be used if there are no packages of that architecture left on the system.

dpkg --print-architecture
amd64

dpkg: error processing archive gcc-4.9-base_4.9.1-19_armhf.deb (--install):
package architecture (armhf) does not match system (amd64)
Errors were encountered while processing:
gcc-4.9-base_4.9.1-19_armhf.deb

dpkg --add-architecture armhf
dpkg --add-architecture armel
dpkg --print-foreign-architectures
armhf
armel

Dpkg -i gcc-4.9-base_4.9.1-19_armhf.deb

Selecting previously unselected package gcc-4.9-base:armhf.
(Reading database ... 86425 files and directories currently installed.)
Preparing to unpack gcc-4.9-base_4.9.1-19_armhf.deb ...
Unpacking gcc-4.9-base:armhf (4.9.1-19) ...
Setting up gcc-4.9-base:armhf (4.9.1-19) ...

Dpkg --remove-architecture armhf

dpkg: error: cannot remove architecture "armhf" currently in use by the database

Dpkg --remove-architecture armel
dpkg --print-foreign-architectures
Multi-architecture support in APT

APT will automatically detect if dpkg is configured to support foreign architectures and will begin downloading the appropriate Packages files during the upgrade process.
Foreign packages can be installed using the apt install package:architecture command.

Using proprietary i386 binaries on amd64 systems

There are several cases where multi-architecture can be useful, but the most common one is to enable 32-bit files (i386) to run on 64-bit systems (amd64), particularly because some popular proprietary applications (like Skype) are only available as 32-bit versions.

Changes related to multi-architecture

To make multi-arch support truly useful, the libraries needed to be repackaged, moving them to an architecture-specific directory so that multiple copies (for different architectures) could be installed at the same time. Such updated packages contain a "Multi-Arch: same" header, indicating to the package management system that different package architectures can be installed together (and that these packages can only satisfy dependencies of packages of the same architecture). Since multi-arch support was only added to Debian Wheezy, not all libraries have been converted yet.

Dpkg -s gcc-4.9-base

dpkg-query: error: --status requires a valid package name, but "gcc-4.9-base" is not: ambiguous package name "gcc-4.9-base" with more than one instance installed

Use the --help option to display help for package queries.

Dpkg -s gcc-4.9-base:amd64 gcc-4.9-base:armhf | grep ^Multi

Multi-Arch: same
Multi-Arch: same

Dpkg -L libgcc1:amd64 |grep .so

/lib/x86_64-linux-gnu/libgcc_s.so.1

Dpkg -S /usr/share/doc/gcc-4.9-base/copyright

gcc-4.9-base:amd64, gcc-4.9-base:armhf: /usr/share/doc/gcc-4.9-base/copyright

It is worth noting that packages with the Multi-Arch: same field should be named with the name of the architecture so that they can be uniquely identified. They may also share files with other instances of the same package; dpkg in this case ensures that all packages have bit-for-bit identical shared files. All instances of the package must be the same version, so they must be updated together.
Multi-architecture support also brings some interesting features into the dependency processing mechanism. Resolving the dependency requires either a package marked "Multi-Arch: foreign" or a package with the same architecture (when resolving the dependency, architecture-independent packages are considered to be of the same architecture as the system). A dependency can also be relaxed to allow a package of any architecture to satisfy it using the package:any syntax, but foreign packages can only satisfy such a dependency if they are marked "Multi-Arch: allowed".

Used materials.

Installing and uninstalling programs is one of the most important things for a computer user. Because we need to somehow get new, necessary programs, and also remove unnecessary ones. But removing packages in Ubuntu has some subtleties. After removal, dependencies may remain, packages installed as recommended, as well as configuration files.

In this article, we will look at how to remove the Ubuntu deb package, and remove it cleanly, so that there are no traces left on the system. We will also talk about completely removing the PPA, since we install many packages that are not in the official repositories from the PPA.

The easiest way to remove an Ubuntu package is to use one of the graphical utilities provided specifically for this purpose, such as Synaptic or Center Ubuntu applications. In fact, this is done in a couple of clicks. First, let's look at the procedure in the Ubuntu Application Center.

You can launch the Application Center from the Unity icon bar:

A list of all installed packages is on the tab Installed Here the applications are sorted into categories:

To remove an Ubuntu package, just left-click on it, and when the available actions appear, click the button Delete:

You will need to enter a password to complete the removal.

The package has been removed, but not quite as we would like. But more on that later.

Next, let's look at the Synaptic package manager. This is no matter how third-party software, but many people use it because of its great functionality and user-friendly interface. If the program is not already installed, you need to install it using the Application Center or by running in the terminal:

sudo apt install synaptic

You can run the program through the terminal by running the command:

Look installed packages you can by selecting the Status tab and then selecting Installed:

You can remove deb ubuntu by simply clicking right click mouse and in the context menu on the required package and selecting mark for deletion or mark for complete removal:

The program will show which other packages will be removed, these are the packages that depend on our package:

Now, to complete the removal, all you have to do is click the button Apply:

Now the program will show which packages will be removed. And the removal process will begin:

Simply deleting and completely deleting differs only in that with complete deletion, configuration files are deleted. But the problem with these tools is that packages installed as dependencies and recommended for the program are not removed and remain on the system. This behavior is observed in both Synaptic and the Ubuntu App Center. Therefore, we move on to describe the most flexible method - removing Ubuntu packages in the terminal.

How to remove an Ubuntu package in the terminal

In new versions of Ubuntu, you can use the new package manager - apt - to manage packages, including removal. The removal command looks like this:

sudo apt remove packagename

The package will be completely removed, including configuration files and dependencies, only recommended programs will remain.

If you want to use apt-get to remove ubuntu deb, then the procedure is slightly different. For normal removal package do:

sudo apt-get remove packagename

To remove a package along with its configuration files, run:

sudo apt-get purge package_name

And in order to also remove dependencies installed with the package, you need to run after one of the previous commands:

sudo apt-get autoremove

Not only explicitly specified dependencies will be removed, but also programs installed as recommended.

Well, we've sorted out the basics, now let's move on to more complex situations. What if you installed a program from a deb file and now you don't know exactly what its package is called in order to remove it?

This is very easy to find out, for example, from an executable file, for example executable file The TimeShift program is located at /usr/bin/timeshift, now we find out its package:

sudo dpkg -S /usr/bin/timeshift

timeshift: /usr/bin/timeshift

As you can see, the package is called timeshift. Now you can remove the Ubuntu program using one of the methods described above.

Very often we install missing software from a PPA, but not all of these packages are needed for a long time, and when updating the system, they can even cause errors. So how do you remove all packages installed from a PPA? For this there is special utility:ppa-purge.

If it is not already installed, install it with the command:

sudo apt install ppa-purge

Now, to remove all packages installed from a specific ppa use:

sudo ppa-purge -i ppa:ppaowner/ppaname

ppa:ppaowner/ppaname - usually all PPAs are written in this format. Protocol: owner/name.

You can find out the list of repositories in the application sources program:

With this command you can remove ubuntu packages installed from ppa in one fell swoop:

find /etc/apt/sources.list.d -type f -name "*.list" -print0 | \
while read -d $"\0" file; do awk -F/ "/deb / && /ppa\.launchpad\.net/ (print "sudo ppa-purge ppa:"$4"/"$5)" "$file"; done

If you installed an application from source code, then it is much more difficult to remove it, because it is not controlled by the package manager, and accordingly the system does not know which files belong to it.

But there is still a way, usually developers use the makefile script file, in addition to the install goal, they implement the uninstall goal, which allows you to perform the opposite action.

Ubuntu 16.04 is already out and provides its users with many very interesting changes, 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 this often get lost, is apt.

What is apt? This is a new package manager for Ubuntu, ready to take over the work of apt-get. It was designed to be friendlier, more efficient and safer. So what did Canonical have in mind when introducing a new package manager? Is there really a difference between apt vs apt-get? This is what we will find out in today’s article.

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

Although these new commands are designed to work similarly to apt-get, they rely 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 outdated tool and its practicality is very questionable. Apt was designed from the ground up to be even more powerful, and it's 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 your package cache. Also you don't need to type apt-cache search to search for packages.

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

Although this is not the only difference from apt-get. The 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 using apt-get there is no simple way see the list of packages available for update. You can simply do 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 abandon apt-get, but they will make it a positive change.

New Apt commands

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

Basic commands:

  • list- list of packages
  • 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 versions of packages
  • full-upgrade- complete system update
  • edit-sources- edit software sources file

You can find more information by running 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 piece of software manager. This tool has been in use for a long time and comes by default in many releases of Ubuntu and Debian. We always used it when we needed to update something, update software, or even just clean out junk from the system.

However, it is becoming outdated. The package manager no longer meets all user needs and is therefore slowly being replaced by apt. Ubuntu developers realize they need to update their package manager to make it simpler, more elegant, and more secure. But for now, both utilities exist in the system, and it’s 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?

Google, it's unclear how I find new programs to install (from the Internet) using apt-get (which is surprisingly powerful and easy from another Linux distribution).

I use Ubuntu Server 8.04 LTS (legacy system used for some odd work) so no GUI.

Anybody have quick advice Here?

I always use package.ubuntu.com

You can also use apt-cache search to apt-cache search on the command line. Or you can use the GUI package manager (Ubuntu Software Center/Synaptic) to search for software.

If you are looking for "nvidia settings".

Apt-cache search nvidia settings

Nvidia-settings - Werkzeug für die Configuration des NVIDIA-Grafiktreibers nvidia-settings-updates - Tool of configuring the NVIDIA graphics driver

You see 2 packages nvidia-settings and nvidia-settings-updates .

To find the associated binary with the nvidia-settings package.

Dpkg -L nvidia-settings | grep bin

/usr/bin /usr/lib/nvidia-settings/bin /usr/lib/nvidia-settings/bin/nvidia-settings

nvidia-settings is the binary name for running the program.

With binaries in particular, there is an application that will automatically launch if you run a command that is not installed. For example,

$ bonnie++ The program "bonnie++" is currently not installed. You can install it by typing: sudo apt-get install bonnie++

In addition, there are search queries: search apt-cache search or aptitude search which may be preferable if you want to really get the filters involved.

I think you mean the name of the binary program included in the package. I use this technique to find it:

just type dpkg -L In the terminal, it will display all the files installed by this package, then you can recognize the names of the binaries by looking at their location. Typically programs are installed in the /usr/bin or /sbin directory.

Let's see an example:

Anwar@edubuntu-lenovo:~$ dpkg -L gnome-screenshot /. /usr /usr/bin /usr/bin/gnome-screenshot /usr/share /usr/share/GConf /usr/share/GConf/gsettings /usr/share/GConf/gsettings/gnome-screenshot.convert /usr/share /applications /usr/share/applications/gnome-screenshot.desktop /usr/share/man /usr/share/man/man1 /usr/share/man/man1/gnome-screenshot.1.gz /usr/share/gnome -screenshot /usr/share/gnome-screenshot/gnome-screenshot.ui /usr/share/glib-2.0 /usr/share/glib-2.0/schemas /usr/share/glib-2.0/schemas/org.gnome.gnome -screenshot.gschema.xml /usr/share/doc /usr/share/doc/gnome-screenshot /usr/share/doc/gnome-screenshot/copyright /usr/share/doc/gnome-screenshot/NEWS.gz /usr /share/doc/gnome-screenshot/changelog.Debian.gz

Note that the gnome-screenshot package program name is gnome-screenshot.

You asked

Whether there is a standard way to know For the desired program?

Sometimes the terminal may indicate your package name, which needs to be installed in order to have the program you want. This happens when the program is in the standard repository and you have enabled that repository.

For example, if I run gnome-documents when such a package is not installed, the terminal will say the following:

Anwar@edubuntu-lenovo:~$ gnome-documents The program "gnome-documents" is currently not installed. You can install it by typing: sudo apt-get install gnome-documents

But in this case I should at least know the name of the program

You can try the "aptitude" program from the command line. This is a graphical package manager. Be sure to add sudo to the program for any actual installations. "sudo aptitude". You can also use aptitude just like apt-get; "sudo aptitude install". I prefer apt-get for single packages that I know the names for.

Also, are you just on the command line? If you have a desktop, you can use System -> Preferences -Synaptic or Ubuntu Software Center. They work almost identically, but they have a simpler batch search.

You can get a (long) list of packages to install by typing apt-get install and then pressing TAB twice (to autocomplete). This is limited because it doesn't tell you what the packages do (Synaptic or Software Center would be better for this), but it can be useful when you can't remember the exact name of the package. You can also enter the first part of the package name (for example, openoffice) to get a shorter list of more relevant packages.

Use the command line tool if you know the package name you need. I don't use software center. You can get the package name through the software center and use it in the terminal if you really need to use the apt-get tool from the command line. And usually the package name is the same as the program name.

you can run (preferably in ~~/.bashrc)

. /etc/bash_completion

when entering:

Sudo apt-get in

it will prompt for installation and then start typing part of the name - for example, nvidia

and you will see the available options starting with nvidia







2024 gtavrl.ru.