Powered By GitBook
102.4. Use Debian package management

102.4 Use Debian package management

Weight: 3
Description: Candidates should be able to perform package management using the Debian package tools.
Key Knowledge Areas:
    Install, upgrade and uninstall Debian binary packages
    Find packages containing specific files or libraries which may or may not be installed
    Obtain package information like version, content, dependencies, package integrity and installation status (whether or not the package is installed)
Terms and Utilities:
    /etc/apt/sources.list
    dpkg
    dpkg-reconfigure
    apt-get
    apt-cache
    aptitude

What is a package?

A package is a piece of software that provides a piece of the system. Examples of packages:
    Linux Kernel
    The C compiler
    The Firefox web browser
    The USB library to interact with USB devices
A package contains the files and other instructions needed to make one Software component work on the system.
Packages have dependencies from other packages that must also be downloaded and installed before installing the package with dependencies.
In old days Linux administrators had to deal with dependency hell for installing a package which caused meta package handlers were born.

What is a Package Manager?

The packet manager is the utility that handles the downloading, unpacking and putting the unpacked pieces in the right places.
The general workflow starts with the user requesting a package using the package manager available in the system. The Package manager then finds the requested package from a known location (called software repository) and downloads it. The Package Manager then installs the package and advises on any manual steps that it finds necessary.
Package management tools help System/Server Administrators in many ways such as:
    Downloading and installing software
    Compile software from source
    Keeping track of all software installed, their updates and upgrades
    Handling dependencies
    and also keeping other information about installed software and many more

What is a Software Repository?

A Linux repository is a storage location from which our system retrieves and installs OS updates and applications. Each repository is a collection of software hosted on a remote server and intended to be used for installing and updating software packages on Linux systems.
Package Manager consists of two entities:
    low-level tool
    high-level too
a low-level tool (such as dpkg or rpm), takes care of the details of unpacking individual packages, running scripts, getting the software installed correctly, while a high-level tool (such as apt-get, yum, or zypper) works with groups of packages, downloads packages from the vendor, and figures out dependencies
The core parts of a linux distro and most of its add-on Software are installed via a Package Management System.
In this course we will talk about package management in Debian based distributions.

dpkg

dpkg is a package manager for Debian-based systems. It can install, remove, and build packages, but unlike other package management systems, it cannot automatically download and install packages or their dependencies.
The dpkg has database and its is located under/var/lib/dpkg directory ;
1
[email protected]:~# ls -l /var/lib/dpkg/
2
total 4416
3
drwxr-xr-x 2 root root 4096 Dec 2 2018 alternatives
4
-rw-r--r-- 1 root root 11 Nov 26 2017 arch
5
-rw-r--r-- 1 root root 170080 Aug 1 2017 available
6
-rw-r--r-- 1 root root 8 Aug 1 2017 cmethopt
7
-rw-r--r-- 1 root root 1214 Jul 1 2018 diversions
8
-rw-r--r-- 1 root root 1133 Jul 1 2018 diversions-old
9
drwxr-xr-x 2 root root 405504 Dec 2 2018 info
10
-rw-r----- 1 root root 0 Dec 2 2018 lock
11
-rw-r----- 1 root root 0 Dec 2 2018 lock-frontend
12
drwxr-xr-x 7 root root 4096 Dec 2 2018 methods
13
drwxr-xr-x 2 root root 4096 Jan 12 2016 parts
14
-rw-r--r-- 1 root root 228 Aug 1 2017 statoverride
15
-rw-r--r-- 1 root root 1948486 Dec 2 2018 status
16
-rw-r--r-- 1 root root 1948486 Dec 2 2018 status-old
17
drwxr-xr-x 2 root root 4096 Dec 1 2018 triggers
18
drwxr-xr-x 2 root root 4096 Dec 2 2018 updates
Copied!
the "status" file contains the list of installed software on the current system.
Lets take a look at most useful switches:
-l | --list list all packages installed on the system ( --get-selection does the same):
1
2
Desired=Unknown/Install/Remove/Purge/Hold
3
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
4
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
5
||/ Name Version Architecture Description
6
+++-==============-============-============-=================================
7
ii a11y-profile-m 0.1.10-0ubun amd64 Accessibility Profile Manager - U
8
ii account-plugin 0.12+16.04.2 all GNOME Control Center account plug
9
ii account-plugin 0.12+16.04.2 all GNOME Control Center account plug
10
ii account-plugin 0.12+16.04.2 all GNOME Control Center account plug
11
...
12
<output has been truncated>
Copied!
To view a specific package installed or not use the option “-l” along with package-name.
dpkg -i | --install ,install a local .deb file :
.deb is extension of the software package format for the Linux distribution Debian.
1
[email protected]:~# dpkg -i zip_3.0-11_amd64.deb
2
(Reading database ... 192789 files and directories currently installed.)
3
Preparing to unpack zip_3.0-11_amd64.deb ...
4
Unpacking zip (3.0-11) over (3.0-11) ...
5
Setting up zip (3.0-11) ...
6
Processing triggers for man-db (2.7.5-1) ...
Copied!
And if a package requires any dependencies you would get into trouble:
1
[email protected]:~# dpkg -i jcal_0.4.1-2_amd64.deb
2
dpkg: warning: downgrading jcal from 0.4.1-2build1 to 0.4.1-2
3
(Reading database ... 192782 files and directories currently installed.)
4
Preparing to unpack jcal_0.4.1-2_amd64.deb ...
5
Unpacking jcal (0.4.1-2) over (0.4.1-2build1) ...
6
dpkg: dependency problems prevent configuration of jcal:
7
jcal depends on libjalali0; however:
8
Package libjalali0 is not installed.
9
10
dpkg: error processing package jcal (--install):
11
dependency problems - leaving unconfigured
12
Processing triggers for man-db (2.7.5-1) ...
13
Errors were encountered while processing:
14
jcal
Copied!
dpkg does not handle dependencies so and we try to install a package one of two thing will happend:
    whether It will completely fail !
    or it will install the package but leave it unconfigured until all dependencies are installed and the apt tool is used to finish the configuration(apt-get install -fwe will see it).
We can also use dpkg --force-dependsto omit dependencies or --force-conflicts to close its eyes to any possible conflicts or --force-reinstallfor reinstalling, but do not forget that any --force command can cause a problem and make the system inconsistent state.
dpkg -L | --listfiles ,To list the files installed by a package:
1
[email protected]:~# dpkg -L zip
2
/.
3
/usr
4
/usr/share
5
/usr/share/doc
6
/usr/share/doc/zip
7
/usr/share/doc/zip/WHATSNEW
8
/usr/share/doc/zip/TODO
9
/usr/share/doc/zip/copyright
10
/usr/share/doc/zip/changelog.Debian.gz
11
/usr/share/man
12
/usr/share/man/man1
13
/usr/share/man/man1/zipsplit.1.gz
14
/usr/share/man/man1/zipcloak.1.gz
15
/usr/share/man/man1/zip.1.gz
16
/usr/share/man/man1/zipnote.1.gz
17
/usr/bin
18
/usr/bin/zipnote
19
/usr/bin/zipcloak
20
/usr/bin/zip
21
/usr/bin/zipsplit
22
/usr/share/doc/zip/changelog.gz
Copied!
dpkg -S | --serach ,If we are not sure which package installed a file, dpkg -S may be able to tell us :
1
[email protected]:~# dpkg -S /usr/bin/zipcloak
2
zip: /usr/bin/zipcloak
Copied!
note:We can also use dpkg -S string and it would do use regular expression search in the file system to find any matches with the string we have types.
dpkg -s | --status ,Check a Package is installed or not:
1
[email protected]:~# dpkg -s zip
2
Package: zip
3
Status: deinstall ok installed
4
Priority: optional
5
Section: utils
6
Installed-Size: 573
7
Maintainer: Ubuntu Developers <[email protected]>
8
Architecture: amd64
9
Multi-Arch: foreign
10
Version: 3.0-11
11
Depends: libbz2-1.0, libc6 (>= 2.14)
12
Recommends: unzip
13
Description: Archiver for .zip files
14
This is InfoZIP's zip program. It produces files that are fully
15
compatible with the popular PKZIP program; however, the command line
16
options are not identical. In other words, the end result is the same,
17
but the methods differ. :-)
18
.
19
This version supports encryption.
20
Original-Maintainer: Santiago Vila <[email protected]>
21
Homepage: http://www.info-zip.org/Zip.html
Copied!
dpkg -c | --contents ,will display the contents of a “.deb” package in long-list format:
1
[email protected]:~# dpkg -c zip_3.0-11_amd64.deb
2
drwxr-xr-x root/root 0 2015-08-16 22:10 ./
3
drwxr-xr-x root/root 0 2015-08-16 22:10 ./usr/
4
drwxr-xr-x root/root 0 2015-08-16 22:10 ./usr/share/
5
drwxr-xr-x root/root 0 2015-08-16 22:10 ./usr/share/doc/
6
drwxr-xr-x root/root 0 2015-08-16 22:11 ./usr/share/doc/zip/
7
-rw-r--r-- root/root 15731 2008-07-01 20:27 ./usr/share/doc/zip/WHATSNEW
8
-rw-r--r-- root/root 6675 2008-06-12 19:03 ./usr/share/doc/zip/TODO
9
-rw-r--r-- root/root 3815 2015-08-16 14:25 ./usr/share/doc/zip/copyright
10
-rw-r--r-- root/root 1040 2015-08-16 22:11 ./usr/share/doc/zip/changelog.Debian.gz
11
drwxr-xr-x root/root 0 2015-08-16 22:10 ./usr/share/man/
12
drwxr-xr-x root/root 0 2015-08-16 22:10 ./usr/share/man/man1/
13
-rw-r--r-- root/root 596 2015-08-16 22:10 ./usr/share/man/man1/zipsplit.1.gz
14
-rw-r--r-- root/root 951 2015-08-16 22:10 ./usr/share/man/man1/zipcloak.1.gz
15
-rw-r--r-- root/root 28488 2015-08-16 22:10 ./usr/share/man/man1/zip.1.gz
16
-rw-r--r-- root/root 793 2015-08-16 22:10 ./usr/share/man/man1/zipnote.1.gz
17
drwxr-xr-x root/root 0 2015-08-16 22:10 ./usr/bin/
18
-rwxr-xr-x root/root 81840 2015-08-16 22:10 ./usr/bin/zipnote
19
-rwxr-xr-x root/root 86224 2015-08-16 22:10 ./usr/bin/zipcloak
20
-rwxr-xr-x root/root 192520 2015-08-16 22:10 ./usr/bin/zip
21
-rwxr-xr-x root/root 81840 2015-08-16 22:10 ./usr/bin/zipsplit
22
lrwxrwxrwx root/root 0 2015-08-16 22:10 ./usr/share/doc/zip/changelog.gz -> CHANGES.gz
Copied!
Do not mess -c with -C, -C checks for partially installed packages.
What is debconf?
When packages are being installed, debconf asks the user questions which determine the contents of the system-wide configuration files associated with that package and stores the user/admin preferences in a database.
Later as the packages are installing, their scripts use the configuration preferences in the database to generate configuration files and otherwise do administrative tasks.This saves the hassle of editing configuration files by hand, and also of waiting for each individual package to install before responding to certain configuration questions.

dpkg-reconfigure

After package installation, it is possible to go back and change the configuration of a package by using the dpkg-reconfigure program (or another program such as Synaptic). For example try:
1
[email protected]:~# dpkg-reconfigure tzdata
Copied!
dpkg -r | --remove , remove a package using its name :
1
[email protected]:~# dpkg -r telnet
2
(Reading database ... 229441 files and directories currently installed.)
3
Removing telnet (0.17-40) ...
4
Processing triggers for man-db (2.7.5-1) ...
Copied!
dpkg cares about dependencies by and does not remove them by default,(which is why it doesn't get .deb file, instead it requires package name inorder to explore dependencies), how ever we can force it withdpkg -r --force-depends command but is NOT recommended. It is better to use a package manager that handles dependencies to ensure that the system is in a consistent state.
note:dpkg -P | --purge purge a package! We can also use ‘P‘ option in place of ‘r’ which will remove the package along with configuration file. The ‘r‘ option will only remove the package and not configuration files.
1
[email protected]:~# dpkg -P vsftpd
2
(Reading database ... 229487 files and directories currently installed.)
3
Removing vsftpd (3.0.3-3ubuntu2) ...
4
Purging configuration files for vsftpd (3.0.3-3ubuntu2) ...
5
Processing triggers for man-db (2.7.5-1) ...
Copied!
Do not get confused -P with -p , -p will print information about package.
dpkg has lots of options and switches try dpkg --help for more information :
1
[email protected]:~# dpkg --help
2
Usage: dpkg [<option> ...] <command>
3
4
Commands:
5
-i|--install <.deb file name> ... | -R|--recursive <directory> ...
6
--unpack <.deb file name> ... | -R|--recursive <directory> ...
7
-A|--record-avail <.deb file name> ... | -R|--recursive <directory> ...
8
--configure <package> ... | -a|--pending
9
--triggers-only <package> ... | -a|--pending
10
-r|--remove <package> ... | -a|--pending
11
-P|--purge <package> ... | -a|--pending
12
-V|--verify <package> ... Verify the integrity of package(s).
13
--get-selections [<pattern> ...] Get list of selections to stdout.
14
--set-selections Set package selections from stdin.
15
--clear-selections Deselect every non-essential package.
16
--update-avail [<Packages-file>] Replace available packages info.
17
--merge-avail [<Packages-file>] Merge with info from file.
18
--clear-avail Erase existing available info.
19
--forget-old-unavail Forget uninstalled unavailable pkgs.
20
-s|--status <package> ... Display package status details.
21
-p|--print-avail <package> ... Display available version details.
22
-L|--listfiles <package> ... List files 'owned' by package(s).
23
-l|--list [<pattern> ...] List packages concisely.
24
-S|--search <pattern> ... Find package(s) owning file(s).
25
-C|--audit [<package> ...] Check for broken package(s).
26
--yet-to-unpack Print packages selected for installation.
27
--predep-package Print pre-dependencies to unpack.
28
--add-architecture <arch> Add <arch> to the list of architectures.
29
--remove-architecture <arch> Remove <arch> from the list of architectures.
30
--print-architecture Print dpkg architecture.
31
--print-foreign-architectures Print allowed foreign architectures.
32
--assert-<feature> Assert support for the specified feature.
33
--compare-versions <a> <op> <b> Compare version numbers - see below.
34
--force-help Show help on forcing.
35
-Dh|--debug=help Show help on debugging.
36
37
-?, --help Show this help message.
38
--version Show the version.
39
40
Assertable features: support-predepends, working-epoch, long-filenames,
41
multi-conrep, multi-arch, versioned-provides.
42
43
Use dpkg with -b, --build, -c, --contents, -e, --control, -I, --info,
44
-f, --field, -x, --extract, -X, --vextract, --ctrl-tarfile, --fsys-tarfile
45
on archives (type dpkg-deb --help).
46
47
Options:
48
--admindir=<directory> Use <directory> instead of /var/lib/dpkg.
49
--root=<directory> Install on a different root directory.
50
--instdir=<directory> Change installation dir without changing admin dir.
51
--path-exclude=<pattern> Do not install paths which match a shell pattern.
52
--path-include=<pattern> Re-include a pattern after a previous exclusion.
53
-O|--selected-only Skip packages not selected for install/upgrade.
54
-E|--skip-same-version Skip packages whose same version is installed.
55
-G|--refuse-downgrade Skip packages with earlier version than installed.
56
-B|--auto-deconfigure Install even if it would break some other package.
57
--[no-]triggers Skip or force consequential trigger processing.
58
--verify-format=<format> Verify output format (supported: 'rpm').
59
--no-debsig Do not try to verify package signatures.
60
--no-act|--dry-run|--simulate
61
Just say what we would do - don't do it.
62
-D|--debug=<octal> Enable debugging (see -Dhelp or --debug=help).
63
--status-fd <n> Send status change updates to file descriptor <n>.
64
--status-logger=<command> Send status change updates to <command>'s stdin.
65
--log=<filename> Log status changes and actions to <filename>.
66
--ignore-depends=<package>,...
67
Ignore dependencies involving <package>.
68
--force-... Override problems (see --force-help).
69
--no-force-...|--refuse-...
70
Stop when problems encountered.
71
--abort-after <n> Abort after encountering <n> errors.
72
73
Comparison operators for --compare-versions are:
74
lt le eq ne ge gt (treat empty version as earlier than any version);
75
lt-nl le-nl ge-nl gt-nl (treat empty version as later than any version);
76
< << <= = >= >> > (only for compatibility with control file syntax).
77
78
Use 'apt' or 'aptitude' for user-friendly package management.
Copied!
When we work with dpkg we have to have .deb package in hand in order to work with. But how about Package Manager?How package manager like apt find software repositories in Debian based systems?

/etc/apt/sources.list

This file contains information about what repositories [online / remote ] the system will use. This file contains lines in the following format:
1
deb location-of-resources distribution component(s)
Copied!
1
[email protected]:~# cat /etc/apt/sources.list
2
# deb cdrom:[Ubuntu 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801)]/ xenial main restricted
3
4
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
5
# newer versions of the distribution.
6
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
7
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
8
9
## Major bug fix updates produced after the final release of the
10
## distribution.
11
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
12
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
13
14
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
15
## team. Also, please note that software in universe WILL NOT receive any
16
## review or updates from the Ubuntu security team.
17
deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
18
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
19
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
20
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
21
22
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
23
## team, and may not be under a free licence. Please satisfy yourself as to
24
## your rights to use the software. Also, please note that software in
25
## multiverse WILL NOT receive any review or updates from the Ubuntu
26
## security team.
27
deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
28
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
29
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
30
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
31
32
## N.B. software from this repository may not have been tested as
33
## extensively as that contained in the main release, although it includes
34
## newer versions of some applications which may provide useful features.
35
## Also, please note that software in backports WILL NOT receive any review
36
## or updates from the Ubuntu security team.
37
deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
38
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
39
40
## Uncomment the following two lines to add software from Canonical's
41
## 'partner' repository.
42
## This software is not part of Ubuntu, but is offered by Canonical and the
43
## respective vendors as a service to Ubuntu users.
44
# deb http://archive.canonical.com/ubuntu xenial partner
45
# deb-src http://archive.canonical.com/ubuntu xenial partner
46
47
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
48
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
49
deb http://security.ubuntu.com/ubuntu xenial-security universe
50
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
51
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
52
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
Copied!
deb lines are relative to binary packages, that we can install with apt. deb-src lines are relative to source packages (as downloaded by apt-get source $package) and next compiled. Source packages are needed only if we want to compile some package ourselves, or inspect the source code for a bug. Ordinary users don't need to include such repositories.
The repository components are:
    Main - Officially supported software.
    Restricted - Supported software that is not available under a completely free license.
    Universe - Community maintained software, i.e. not officially supported software.
    Multiverse - Software that is not free.
Some distributions like Ubuntu also have /etc/apt/sources.list.d directory which provides a way to add sources.list entries in separate .list files.
1
[email protected]:/# ls /etc/apt/sources.list.d
2
peek-developers-ubuntu-stable-xenial.list
3
[email protected]:/# cat /etc/apt/sources.list.d/peek-developers-ubuntu-stable-xenial.list
4
deb http://ppa.launchpad.net/peek-developers/stable/ubuntu xenial main
5
# deb-src http://ppa.launchpad.net/peek-developers/stable/ubuntu xenial main
Copied!
All .list files are compiled and added to /etc/apt/sources.list file.

APT (Advanced Packaging Tool)

It is a very popular, free, powerful and useful command line package management system that is a front end for dpkg package management system.Initially it was designed for Debian’s.debpackages
Apt is whole command line with no GUI. Whenever invoked from command line along with specifying the name of package to be installed, it finds that package in configured list of sources specified in ‘/etc/apt/sources.list’ along with the list of dependencies for that package and sorts them and automatically installs them along with the current package thus letting user not to worry of installing dependencies.
It is consist of two commands:
    apt-get
    apt-cache

What is apt-get?

The apt-get is the command-line tool for working with APT software packages, that is used to work with Ubuntu’s APT (Advanced Packaging Tool) library to perform installation of new software packages, removing existing software packages, upgrading of existing software packages and even used to upgrading the entire operating system.
apt-get update
This will help us to download a list of packages from different repositories included on our system and updates them when there are new versions of packages and their dependencies. (After any modification in repositories we have to run apt-update manually other wise, system local cache from previous repositories will be used)
1
[email protected]:/# apt-get update
2
Hit:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease
3
Hit:2 http://security.ubuntu.com/ubuntu xenial-security InRelease
4
Hit:3 http://ppa.launchpad.net/peek-developers/stable/ubuntu xenial InRelease
5
Hit:4 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease
6
Hit:5 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease
7
Reading package lists... Done
8
Building dependency tree
9
Reading state information... Done
10
287 packages can be upgraded. Run 'apt list --upgradable' to see them.
Copied!
to see what packages can be upgraded:
1
[email protected]:/# apt-get list --upgradable
2
Listing... Done
3
appstream/xenial-updates 0.9.4-1ubuntu4 amd64 [upgradable from: 0.9.4-1ubuntu3]
4
apt/xenial-updates 1.2.29 amd64 [upgradable from: 1.2.24]
5
apt-transport-https/xenial-updates 1.2.29 amd64 [upgradable from: 1.2.24]
6
apt-utils/xenial-updates 1.2.29 amd64 [upgradable from: 1.2.24]
7
apturl/xenial-updates 0.5.2ubuntu11.2 amd64 [upgradable from: 0.5.2ubuntu11.1]
8
apturl-common/xenial-updates 0.5.2ubuntu11.2 amd64 [upgradable from: 0.5.2ubuntu11.1]
9
avahi-autoipd/xenial-updates 0.6.32~rc+dfsg-1ubuntu2.2 amd64 [upgradable from: 0.6.32~rc+dfsg-1ubuntu2]
10
...
11
<the output has been truncated>
Copied!
apt-get upgrade
The ‘upgrade‘ command is used to upgrade all the currently installed software packages on the system. Under any circumstances currently installed packages are not removed or packages which are not already installed neither retrieved and installed to satisfy upgrade dependencies.
New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version.
An update must be performed first so that apt-get knows that new versions of packages are available.
1
[email protected]:/# apt-get upgrade
2
Reading package lists... Done
3
Building dependency tree
4
Reading state information... Done
5
Calculating upgrade... Done
6
The following packages were automatically installed and are no longer required:
7
libecap3 squid squid-common squid-langpack
8
Use 'apt autoremove' to remove them.
9
The following packages have been kept back:
10
libdrm-amdgpu1 libdrm2 libegl1-mesa libgbm1 libgl1-mesa-dri libmm-glib0
11
libqmi-proxy libwayland-egl1-mesa libxatracker2 linux-generic-hwe-16.04
12
linux-headers-generic-hwe-16.04 linux-image-generic-hwe-16.04
13
mesa-vdpau-drivers modemmanager ubuntu-minimal
14
The following packages will be upgraded:
15
appstream apt apt-transport-https apt-utils apturl apturl-common
16
avahi-autoipd avahi-daemon avahi-utils bamfdaemon base-files binutils
17
bsdutils compiz compiz-core compiz-gnome compiz-plugins-default
18
console-setup console-setup-linux cracklib-runtime desktop-file-utils dpkg
19
dpkg-dev firefox firefox-locale-en fonts-opensymbol friendly-recovery fwupd
20
fwupdate fwupdate-signed gettext gettext-base ghostscript ghostscript-x
21
...
22
<the output has been truncated>
23
...
24
update-notifier-common ure util-linux uuid-runtime va-driver-all
25
wireless-regdb x11-common xdg-user-dirs xorg xserver-common
26
xserver-xorg-video-amdgpu-hwe-16.04 xserver-xorg-video-ati-hwe-16.04
27
xserver-xorg-video-intel-hwe-16.04 xserver-xorg-video-nouveau-hwe-16.04
28
xserver-xorg-video-radeon-hwe-16.04
29
272 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
30
Need to get 276 MB of archives.
31
After this operation, 23.1 MB of additional disk space will be used.
32
Do you want to continue? [Y/n] y
33
Get:1 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 base-files amd64 9.4ubuntu4.7 [65.9 kB]
34
Get:2 http://ppa.launchpad.net/peek-developers/stable/ubuntu xenial/main amd64 peek amd64 1.3.1-0~ppa23~ubuntu16.04.1 [163 kB]
35
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 bsdutils amd64 1:2.27.1-6ubuntu3.6 [51.2 kB]
36
...
37
<the output has been truncated>
38
...
39
Get:252 http://mirror.iranserver.com/ubuntu xenial-updates/main amd64 xserver-xorg-video-nouveau-hwe-16.04 amd64 1:1.0.15-2~16.04.1 [87.0 kB]
40
Fetched 270 MB in 4min 49s (933 kB/s)
41
Extracting templates from packages: 100%
42
Preconfiguring packages ...
43
(Reading database ... 192776 files and directories currently installed.)
44
Preparing to unpack .../base-files_9.4ubuntu4.7_amd64.deb ...
45
Unpacking base-files (9.4ubuntu4.7) over (9.4ubuntu4.5) ...
46
Processing triggers for cracklib-runtime (2.9.2-1build2) ...
47
Processing triggers for man-db (2.7.5-1) ...
48
...
Copied!
apt-get dist-upgrade
dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages (including the kernel)
If we want to upgrade, unconcerned of whether software packages will be added or removed to fulfill dependencies, use the ‘dist-upgrade‘ sub command.
apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary.
1
[email protected]:~# apt-get dist-upgrade
2
Reading package lists... Done
3
Building dependency tree
4
Reading state information... Done
5
Calculating upgrade... Done
6
The following packages were automatically installed and are no longer required:
7
libecap3 squid squid-common squid-langpack
8
Use 'apt autoremove' to remove them.
9
The following NEW packages will be installed:
10
amd64-microcode intel-microcode iucode-tool libdrm-common libllvm6.0
11
libqmi-glib5 linux-headers-4.15.0-39 linux-headers-4.15.0-39-generic
12
linux-image-4.15.0-39-generic linux-modules-4.15.0-39-generic
13
linux-modules-extra-4.15.0-39-generic ubuntu-advantage-tools
14
The following packages will be upgraded:
15
libdrm-amdgpu1 libdrm2 libegl1-mesa libgbm1 libgl1-mesa-dri libmm-glib0
16
libqmi-proxy libwayland-egl1-mesa libxatracker2 linux-generic-hwe-16.04
17
linux-headers-generic-hwe-16.04 linux-image-generic-hwe-16.04
18
mesa-vdpau-drivers modemmanager ubuntu-minimal
19
15 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
20
Need to get 91.8 MB of archives.
21
After this operation, 428 MB of additional disk space will be used.
22
Do you want to continue? [Y/n]
23
...
24
Get:1 http://mirror.iranserver.com/ubuntu xenial-updates/main amd64 ubuntu-advantage-tools all 10ubuntu0.16.04.1 [11.5 kB]
25
Get:2 http://mirror.iranserver.com/ubuntu xenial-updates/main amd64 ubuntu-minimal amd64 1.361.2 [2,662 B]
26
Get:3 http://mirror.iranserver.com/ubuntu xenial-updates/main amd64 libdrm-common all 2.4.91-2~16.04.1 [4,764 B]
27
Get:4 http://mirror.iranserver.com/ubuntu xenial-updates/main amd64 libdrm2 amd64 2.4.91-2~16.04.1 [30.8 kB]
28
Get:5 http://mirror.iranserver.com/ubuntu xenial-updates/main amd64 iucode-tool amd64 1.5.1-1ubuntu0.1 [33.8 kB]
29
Get:6 http://mirror.iranserver.com/ubuntu xenial-updates/main amd64 libdrm-amdgpu1 amd64 2.4.91-2~16.04.1 [18.9 kB]
30
...
31
Fetched 91.8 MB in 53s (1,725 kB/s)
32
Selecting previously unselected package ubuntu-advantage-tools.
33
(Reading database ... 192821 files and directories currently installed.)
34
Preparing to unpack .../ubuntu-advantage-tools_10ubuntu0.16.04.1_all.deb ...
35
Unpacking ubuntu-advantage-tools (10ubuntu0.16.04.1) ...
36
Preparing to unpack .../ubuntu-minimal_1.361.2_amd64.deb ...
37
Unpacking ubuntu-minimal (1.361.2) over (1.361) ...
38
Selecting previously unselected package libdrm-common.
39
Preparing to unpack .../libdrm-common_2.4.91-2~16.04.1_all.deb ...
40
Unpacking libdrm-common (2.4.91-2~16.04.1) ...
41
Preparing to unpack .../libdrm2_2.4.91-2~16.04.1_amd64.deb ...
42
Unpacking libdrm2:amd64 (2.4.91-2~16.04.1) over (2.4.76-1~ubuntu16.04.1) ...
43
Selecting previously unselected package iucode-tool.
44
Preparing to unpack .../iucode-tool_1.5.1-1ubuntu0.1_amd64.deb ...
45
Unpacking iucode-tool (1.5.1-1ubuntu0.1) ...
46
...
Copied!
apt-get autoremove
The ‘autoremove‘ sub command is used to auto remove packages that were certainly installed to satisfy dependencies for other packages and but they were now no longer required. For example:
1
[email protected]:~# apt-get autoremove
2
Reading package lists... Done
3
Building dependency tree
4
Reading state information... Done
5
The following packages will be REMOVED:
6
libecap3 squid squid-common squid-langpack
7
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
8
After this operation, 10.8 MB disk space will be freed.
9
Do you want to continue? [Y/n] y
10
(Reading database ... 228575 files and directories currently installed.)
11
Removing squid (3.5.12-1ubuntu7.6) ...
12
Removing libecap3:amd64 (1.0.1-3ubuntu3) ...
13
Removing squid-common (3.5.12-1ubuntu7.6) ...
14
Removing squid-langpack (20150704-1) ...
15
Processing triggers for man-db (2.7.5-1) ...
16
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Copied!
apt-get install
Install a package as follows by specify a single package name or install many packages at once by listing all their names:
1
[email protected]:~# apt-get install vsftpd
2
Reading package lists... Done
3
Building dependency tree
4
Reading state information... Done
5
The following packages were automatically installed and are no longer required:
6
openbsd-inetd pure-ftpd-common
7
Use 'apt autoremove' to remove them.
8
The following packages will be REMOVED:
9
pure-ftpd
10
The following NEW packages will be installed:
11
vsftpd
12
0 upgraded, 1 newly installed, 1 to remove and 2 not upgraded.
13
Need to get 115 kB of archives.
14
After this operation, 213 kB disk space will be freed.
15
Do you want to continue? [Y/n] y
16
Get:1 http://mirror.hmc.edu/ubuntu xenial/main amd64 vsftpd amd64 3.0.3-3ubuntu2 [115 kB]
17
Fetched 115 kB in 7s (15.8 kB/s)
18
Preconfiguring packages ...
19
(Reading database ... 229455 files and directories currently installed.)
20
Removing pure-ftpd (1.0.36-3.2build1) ...
21
Processing triggers for man-db (2.7.5-1) ...
22
Selecting previously unselected package vsftpd.
23
(Reading database ... 229443 files and directories currently installed.)
24
Preparing to unpack .../vsftpd_3.0.3-3ubuntu2_amd64.deb ...
25
Unpacking vsftpd (3.0.3-3ubuntu2) ...
26
Processing triggers for systemd (229-4ubuntu21.10) ...
27
Processing triggers for ureadahead (0.100.0-19) ...
28
Processing triggers for man-db (2.7.5-1) ...
29
Setting up vsftpd (3.0.3-3ubuntu2) ...
30
Installing new version of config file /etc/ftpusers ...
31
Processing triggers for systemd (229-4ubuntu21.10) ...
32
Processing triggers for ureadahead (0.100.0-19) ...
Copied!
apt-get remove
Remove Packages without their Configuration Files:
1
[email protected]:~# apt-get remove vsftpd
2
Reading package lists... Done
3
Building dependency tree
4
Reading state information... Done
5
The following packages were automatically installed and are no longer required:
6
openbsd-inetd pure-ftpd-common
7
Use 'apt autoremove' to remove them.
8
The following packages will be REMOVED:
9
vsftpd
10
0 upgraded, 0 newly installed, 1 to remove and 2 not upgraded.
11
After this operation, 336 kB disk space will be freed.
12
Do you want to continue? [Y/n] y
13
(Reading database ... 229498 files and directories currently installed.)
14
Removing vsftpd (3.0.3-3ubuntu2) ...
15
Processing triggers for man-db (2.7.5-1) ...
Copied!
apt-get purge
apt with remove, it only removes the package files but configuration files remain on the system. Therefore to remove a package and it’s configuration files, we will have to use purge.
1
[email protected]:~# apt-get purge vsftpd
2
Reading package lists... Done
3
Building dependency tree
4
Reading state information... Done
5
The following packages were automatically installed and are no longer required:
6
openbsd-inetd pure-ftpd-common
7
Use 'apt autoremove' to remove them.
8
The following packages will be REMOVED:
9
vsftpd*
10
0 upgraded, 0 newly installed, 1 to remove and 2 not upgraded.
11
After this operation, 0 B of additional disk space will be used.
12
Do you want to continue? [Y/n] y
13
(Reading database ... 229446 files and directories currently installed.)
14
Removing vsftpd (3.0.3-3ubuntu2) ...
15
Purging configuration files for vsftpd (3.0.3-3ubuntu2) ...
Copied!

apt-get clean

To delete downloaded packages (.deb) already installed (and no longer needed) and it would free up more space by cleaning the cache.
1
[email protected]:~# apt-get clean
Copied!

apt-get autoclean

To remove all stored archives in your cache for packages that can not be downloaded anymore (thus packages that are no longer in the repository or that have a newer version in the repository).
1
[email protected]:~# apt-get autoclean
2
Reading package lists... Done
3
Building dependency tree
4
Reading state information... Done
Copied!

apt-get check

Will check the the currently installed packages for any broken installation.
1
[email protected]:~# apt-get check
2
Reading package lists... Done
3
Building dependency tree
4
Reading state information... Done
Copied!

What is apt-cache?

The apt-cache command line tool is used for searching apt software package cache. In simple words, this tool is used to search software packages, collects information of packages and also used to search for what available packages are ready for installation on Debian or Ubuntu based systems. APTs cached files are located in/var/cache/apt/archives/
Before start using apt-cache it is good to do apt-get check first:
1
[email protected]:~# apt-get check
2
Reading package lists... Done
3
Building dependency tree
4
Reading state information... Done
Copied!
Because this command builds new cache by comparing the current state with the state of packages as listed in repositories. One the apt-cache has been built we can query it.
apt-cache search
Find Out Package Name and Description of Software (doesn't require root access because it is querying the cache)
1
[email protected]:~# apt-cache search netcat
2
netcat-openbsd - TCP/IP swiss army knife
3
corkscrew - tunnel TCP connections through HTTP proxies
4
cryptcat - A lightweight version netcat extended with twofish encryption
5
kafkacat - generic producer and consumer for Apache Kafka
6
libexpect-perl - Expect.pm - Perl Expect interface
7
netcat - TCP/IP swiss army knife -- transitional package
8
netcat-traditional - TCP/IP swiss army knife
9
netrw - netcat like tool with nice features to transport files over network
10
netsed - network packet-altering stream editor
11
socat - multipurpose relay for bidirectional data transfer
Copied!
apt-cache show
Check information of package along with it short description say (version number, check sums, size, installed size, category etc).
1
[email protected]:~# apt-cache show netcat
2
Package: netcat
3
Priority: optional
4
Section: universe/net
5
Installed-Size: 30
6
Maintainer: Ubuntu Developers <[email protected]>
7
Original-Maintainer: Ruben Molina <[email protected]>
8
Architecture: all
9
Version: 1.10-41
10
Depends: netcat-traditional (>= 1.10-39)
11
Filename: pool/universe/n/netcat/netcat_1.10-41_all.deb
12
Size: 3438
13
MD5sum: ef404dcc16fdf7b7fc049e8499b5d6dd
14
SHA1: 6445cd6789821840978146ef1d33a2475e092c42
15
SHA256: 1865119bdf88c21df3c039f987492defac68668bf7293ba279e76943c0fd1785
16
Description-en: TCP/IP swiss army knife -- transitional package
17
This is a "dummy" package that depends on lenny's default version of
18
netcat, to ease upgrades. It may be safely removed.
19
Description-md5: 1353f8c1d079348417c2180319bdde09
20
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Copied!
apt-cache showpkg
‘showpkg‘ sub command to check the dependencies for particular software packages. whether those dependencies packages are installed or not.
1
[email protected]:~# apt-cache showpkg netcat
2
Package: netcat
3
Versions:
4
1.10-41 (/var/lib/apt/lists/mirror.iranserver.com_ubuntu_dists_xenial_universe_binary-amd64_Packages) (/var/lib/apt/lists/mirror.iranserver.com_ubuntu_dists_xenial_universe_binary-i386_Packages) (/var/lib/dpkg/status)
5
Description Language:
6
File: /var/lib/apt/lists/mirror.iranserver.com_ubuntu_dists_xenial_universe_binary-amd64_Packages
7
MD5: 1353f8c1d079348417c2180319bdde09
8
Description Language: en
9
File: /var/lib/apt/lists/mirror.iranserver.com_ubuntu_dists_xenial_universe_i18n_Translation-en
10
MD5: 1353f8c1d079348417c2180319bdde09
11
12
13
Reverse Depends:
14
netcat-openbsd,netcat 1.10-35
15
playonlinux,netcat
16
tomcat8-user,netcat
17
tomcat7-user,netcat
18
ltsp-client-core,netcat
19
ltsp-client,netcat
20
...
21
Dependencies:
22
1.10-41 - netcat-traditional (2 1.10-39)
23
Provides:
24
1.10-41 -
25
Reverse Provides:
26
netcat-traditional 1.10-41 (= )
27
netcat-openbsd 1.105-7ubuntu1 (= )
Copied!
apt-cache depends and apt-cache rdepends allow us to query dependencies.
1
[email protected]:~# apt-cache depends telnet
2
telnet
3
Depends: netbase
4
Depends: libc6
5
Depends: libstdc++6
6
Replaces: <netstd>
7
[email protected]:~# apt-cache rdepends telnet
8
telnet
9
Reverse Depends:
10
ubuntu-standard
11
ubuntu-standard
12
|zssh
13
tucnak
14
ser2net
15
procserv
16
mininet
17
|matanza
18
libtelnet-utils
19
libtelnet-dev
20
lavapdu-daemon
21
|dish
22
|coturn
23
coldfire
Copied!
See telnet dependencies and see which other packages depends on telnet.
use apt-cache stat to show statistics of installed packages on your computer.
dselect
dselect is a front-end to dpkg that is used to manage software packages in Debian and Debian-based Linux distributions. You can use dselect to install packages on your system from the APT archives defined in /etc/apt/sources.list, review the already installed packages, uninstall and upgrade packages.

aptitude

aptitude is another high-level package manager for Debian-based systems, and can be used to perform management tasks (installing, upgrading, and removing packages, also handling dependency resolution automatically) in a fast and easy way. It provides the same functionality as apt-get and additional ones, such as offering access to several versions of a package.
You might need to install aptitude first ( apt-get install aptitude )
1
[email protected]:~#apt-get install aptitude
2
3
[email protected]:~# aptitude --help
4
aptitude 0.7.4
5
Usage: aptitude [-S fname] [-u|-i]
6
aptitude [options] <action> ...
7
Actions (if none is specified, aptitude will enter interactive mode):
8
9
install - Install/upgrade packages.
10
remove - Remove packages.
11
purge - Remove packages and their configuration files.
12
hold - Place packages on hold.
13
unhold - Cancel a hold command for a package.
14
markauto - Mark packages as having been automatically installed.
15
unmarkauto - Mark packages as having been manually installed.
16
forbid-version - Forbid aptitude from upgrading to a specific package version.
17
update - Download lists of new/upgradable packages.
18
safe-upgrade - Perform a safe upgrade.
19
full-upgrade - Perform an upgrade, possibly installing and removing packages.
20
build-dep - Install the build-dependencies of packages.
21
forget-new - Forget what packages are "new".
22
search - Search for a package by name and/or expression.
23
show - Display detailed information about a package.
24
versions - Displays the versions of specified packages.
25
clean - Erase downloaded package files.
26
autoclean - Erase old downloaded package files.
27
changelog - View a package's changelog.
28
download - Download the .deb file for a package.
29
reinstall - Download and (possibly) reinstall a currently installed package.
30
why - Show the manually installed packages that require a package, or
31
why one or more packages would require the given package.
32
why-not - Show the manually installed packages that lead to a conflict
33
with the given package, or why one or more packages would
34
lead to a conflict with the given package if installed.
35
36
Options:
37
-h This help text.
38
--no-gui Do not use the GTK GUI even if available.
39
-s Simulate actions, but do not actually perform them.
40
-d Only download packages, do not install or remove anything.
41
-P Always prompt for confirmation of actions.
42
-y Assume that the answer to simple yes/no questions is 'yes'.
43
-F format Specify a format for displaying search results; see the manual.
44
-O order Specify how search results should be sorted; see the manual.
45
-w width Specify the display width for formatting search results.
46
-f Aggressively try to fix broken packages.
47
-V Show which versions of packages are to be installed.
48
-D Show the dependencies of automatically changed packages.
49
-Z Show the change in installed size of each package.
50
-v Display extra information. (may be supplied multiple times).
51
-t [release] Set the release from which packages should be installed.
52
-q In command-line mode, suppress the incremental progress
53
indicators.
54
-o key=val Directly set the configuration option named 'key'.
55
--with(out)-recommends Specify whether or not to treat recommends as
56
strong dependencies.
57
-S fname Read the aptitude extended status info from fname.
58
-u Download new package lists on startup.
59
(terminal interface only)
60
-i Perform an install run on startup.
61
(terminal interface only)
62
63
This aptitude does not have Super Cow Powers.
Copied!
As an example lets search and get info about netcat using aptitude:
1
[email protected]:~# aptitude update
2
Hit http://mirror.iranserver.com/ubuntu xenial InRelease
3
Get: 1 http://mirror.iranserver.com/ubuntu xenial-updates InRelease [109 kB]
4
Hit http://ppa.launchpad.net/peek-developers/stable/ubuntu xenial InRelease
5
Get: 2 http://mirror.iranserver.com/ubuntu xenial-backports InRelease [107 kB]
6
Get: 3 http://mirror.iranserver.com/ubuntu xenial-security InRelease [107 kB]
7
Fetched 323 kB in 1s (208 kB/s)
8
9
[email protected]:~# aptitude search netcat
10
i netcat - TCP/IP swiss army knife -- transitional p
11
v netcat:i386 -
12
i netcat-openbsd - TCP/IP swiss army knife
13
p netcat-openbsd:i386 - TCP/IP swiss army knife
14
i A netcat-traditional - TCP/IP swiss army knife
15
p netcat-traditional:i386 - TCP/IP swiss army knife
16
17
[email protected]:~# aptitude show netcat
18
[ 0%] Reading package lists
19
Package: netcat
20
State: installed
21
Automatically installed: no
22
Version: 1.10-41
23
Priority: optional
24
Section: universe/net
25
Maintainer: Ubuntu Developers <[email protected]>
26
Architecture: all
27
Uncompressed Size: 30.7 k
28
Depends: netcat-traditional (>= 1.10-39)
29
Provided by: netcat-openbsd (1.105-7ubuntu1), netcat-traditional (1.10-41)
30
Description: TCP/IP swiss army knife -- transitional package
31
This is a "dummy" package that depends on lenny's default version of netcat,
32
to ease upgrades. It may be safely removed.
Copied!
Differences Between APT and Aptitude
Apart from main difference being that Aptitude is a high-level package manager while APT is lower-level package manager which can be used by other higher-level package managers, other main highlights that separate these two package managers are:
    Aptitude is vaster in functionality than apt-get and integrates functionalities of apt-get and its other variants including apt-cache and apt-mark.
    While apt-get lacks UI, Aptitude has a text-only and interactive UI
    Aptitude has a better package management than apt-get:
1.While removing any installed package, Aptitude will automatically remove unused packages, while apt-get would need user to explicitly specify this by either adding additional option of ‘—auto-remove’ or specifying ‘apt-get autoremove’.
2.To investigate further as to why certain action is getting blocked or why or why-not a certain action should be taken, Aptitude offers 'why' and ‘why-not’ commands.
3.While apt-get would probably die-out in case of conflicting action regarding installation or removal of package with a message, Aptitude can suggest possible measures to remove that conflict.

Summary

Debian Family System
dpkg:
    low-level or underlying packet manager
    Unpacks, installs, removes and build packages
    It can't download or resolve dependencies
Advance Package Tool (apt) :
    Build on top of dpkg (depends on it)
    works with groups of packages
    It can automatically download and install packages to figure out and resolve dependencies.
    Tts native user interface is through the apt-get and apt-cache commands
    Usually a user interface is created on top of it for an specific distro (SW update GUIs are an example of this)
.
.
.
sources:
Last modified 5mo ago