Most applications on Linux are OpenSource. 1
We are provided with the source files of the application, and in order to run it on our platform, 2
we have to either compile the sources or install it from a binary package. 3
A binary package in the Linux context is an application package which contains executables as opposed 4
to source code. 5
The executables are the outcome of the compilation process. In this lecture will discuss how to manage 6
the software applications on Ubuntu and other Debian based distributions like Linux Mint, MX 7
Linux or Kali using dpkg. 8
Deb is the installation package format used by all Debian based distributions. 9
This is, in fact, an archive that contains other files, including the executable application that 10
was already compiled. 11
Btw, the name deb, comes from Debra which is the wife’s name of the Debian founder. 12
I'm downloading Google Chrome, which comes 13
as a deb package. 14
Instead of installing it I just want to see its contents. 15
I'm saving the file. 16
Perfect. 17
It was saved in the downloads directory, in the user's home directory. 18
Here; instead of installing the program, I want to see its contents. 19
I am clicking with the right mouse button on the file and then select open with other applications. 20
And I'm clicking on archive manager. 21
And select. 22
This is the context of the Dab file. 23
And we see that inside the tape file, which is an archive, 24
there are two other archives. 25
One archive contains metadata information about the version, the release, the dependencies and so 26
on. 27
And the other one contains the application files. 28
Package management operations can be performed with different tools available, from the lowest level 29
command dpkg to apt or graphical front-ends like Synaptic. 30
dpkg provides the low-level infrastructure for package management. The dpkg database contains the 31
list of the installed software on the current system. 32
It can work with local .deb package files and does not know about repositories and does not solve dependencies 33
like apt does. 34
Note that other advanced tools like apt will call dpkg behind the scenes. 35
So they are based on dpkg. 36
If you have a local downloaded application is a deb file, you can install it using dpkg. 37
I'm moving to the directory where Chrome was downloaded. 38
So cd downloads 39
this is the deb file; dlet's display information about the Chrome deb package and then install it. 40
dpkg --info and the name of the file 41
And we see lots of information and to install the package run dpkg with the -i option: 42
Only root can manage applications on Linux. 43
So sudo dpkg -i and the name of the deb file; it's extracting and installing Google Chrome. 44
The Chrome Browser. 45
It was successfully installed. 46
I can start it. 47
If you want to install more packages at once, you don't have to run thedpkg command multiple times, 48
just provide all deb files as arguments to a single dpkg 49
command. 50
This is especially useful if there's a circular dependancy. 51
Take a look at this image: package A depends on package B, which depends on package C, which in turn 52
depends on package A. 53
In this case, you need to give all three packages in the same line to dpkg. 54
Let's return to the terminal! To get a list of all installed packages run dpkg --get 55
-selections 56
These are all installed programs on the system! Or if you want to see the package version of the 57
architecture and the short description run dpkg-query with the -I option. 58
So dpkg- 59
query-l 60
And you can filter the output using grep, so grep chrome 61
It has displayed the information about Chrome. The first two letters, double i in this case, indicate 62
the desired state which is “install” and the packet status which is “installed”. A Debian package, 63
is an archive that contains other files. 64
If you are to list all files installed on your system from a package run dpkg with the - 65
L option and the package name. 66
The first step is to find the exact name of the package. 67
So I'm running dpkg-query -l | grep chrome 68
This is the exact name of the package. 69
I'm copying it to the clipboard and dpkg -L and the package name 70
I'm pasting it. 71
These are all the files from the package. Let's see another example dpkg-query -l | grep 72
ssh 73
This is the name of the OpenSsh server package. 74
So the dpkg -L and the name of the packege 75
Great, if you want to see to what package a specific file belongs to, then use the capital S option. 76
Suppose an important file got corrupted and you want to reinstall the package; let's see to which package 77
the ls command belongs : which - a ls and dpkg -S /bin/ls 78
I am taking the second path and we see that the package that contains the ls command is called coreutils. And 79
to see all the other files from this package run dpkg -L and the package name coreutils 80
I'm piping the output to less. 81
And we notice that this package contains the core utilities of the system cp, mkdir, mv, rm, touch 82
and so on are some of the most used and well known Linux commands 83
To remove an already installed package, use the -r or -- remove option and the package 84
name. Let's remove the Chrome browser so sudo dpkg -r 85
an the name of the package 86
google-chrome-stable 87
Note that the -r option does not remove the configuration file as well. If you reinstall the package you’ll 88
have the same configuration. 89
If you want to remove both the application and the configuration files, use the capital P or -- 90
purge option. 91
So dkpg -P and the name of the package. 92
And of course run it as root. 93
You've just learned the basics of package management using dpkg on Debian based distributions. 94
However dpkd is a low-level tool that neither works with repositories nor solves dependency problems. 95
The recommended way of managing packages on a Debian based system is to use the apt tool. We’ll take a 96
short break and in the next lecture we’ll discuss apt.