1
00:00:00,090 --> 00:00:00,960
In this lesson,

2
00:00:00,960 --> 00:00:03,423
we're going to cover the Debian packages and APT.

3
00:00:04,290 --> 00:00:07,050
Debian is one of the most prominent Linux distributions

4
00:00:07,050 --> 00:00:09,240
and it has its own package manager.

5
00:00:09,240 --> 00:00:11,100
There are various programs that Debian has

6
00:00:11,100 --> 00:00:12,540
for managing its packages.

7
00:00:12,540 --> 00:00:16,620
However, we're going to focus mainly on DPKG and APT

8
00:00:16,620 --> 00:00:17,850
since there are multiple tools

9
00:00:17,850 --> 00:00:19,710
that are used to manage Debian packages

10
00:00:19,710 --> 00:00:21,750
from graphic and text based interfaces

11
00:00:21,750 --> 00:00:24,240
to low level tools that are used to install packages.

12
00:00:24,240 --> 00:00:28,440
But as I said, our focus is going to be on DPKG and APT

13
00:00:28,440 --> 00:00:31,650
'cause those are clearly listed out in your exam objectives.

14
00:00:31,650 --> 00:00:33,240
Now the main package management program

15
00:00:33,240 --> 00:00:36,180
that Debian uses is DPKG.

16
00:00:36,180 --> 00:00:41,180
The DPKG command does use .deb files as its packages.

17
00:00:41,730 --> 00:00:44,520
DPKG is the command that's used to manage packages

18
00:00:44,520 --> 00:00:47,700
on Debian derived distributions, including Kali Linux

19
00:00:47,700 --> 00:00:50,130
that you'll use as a penetration tester.

20
00:00:50,130 --> 00:00:51,990
It includes lots of different options

21
00:00:51,990 --> 00:00:54,570
including -i and the package name

22
00:00:54,570 --> 00:00:56,910
which is used to install the package,

23
00:00:56,910 --> 00:00:59,310
r and the package name, which is used to remove

24
00:00:59,310 --> 00:01:01,290
or uninstall the package,

25
00:01:01,290 --> 00:01:02,670
l and the package name

26
00:01:02,670 --> 00:01:04,050
which is used to list information

27
00:01:04,050 --> 00:01:05,910
about the specified package.

28
00:01:05,910 --> 00:01:07,590
If you don't provide a package name,

29
00:01:07,590 --> 00:01:08,423
it's going to go ahead

30
00:01:08,423 --> 00:01:10,440
and list all of your installed packages.

31
00:01:10,440 --> 00:01:12,750
And then -s and the package name,

32
00:01:12,750 --> 00:01:13,800
which is used to report about

33
00:01:13,800 --> 00:01:16,110
whether a package is actually installed or not.

34
00:01:16,110 --> 00:01:17,670
For example, you might go

35
00:01:17,670 --> 00:01:20,100
is an Apache web server installed on the system?

36
00:01:20,100 --> 00:01:24,750
And you could type in dpkg -s apache2 and hit enter,

37
00:01:24,750 --> 00:01:26,040
and then find out whether or not

38
00:01:26,040 --> 00:01:27,990
Apache2 is already installed.

39
00:01:27,990 --> 00:01:29,700
To run the DPKG command,

40
00:01:29,700 --> 00:01:34,200
simply type in dpkg, the options and the package name.

41
00:01:34,200 --> 00:01:37,080
Now you may be wondering when you use DPKG

42
00:01:37,080 --> 00:01:39,600
and you install a component, does it also ensure

43
00:01:39,600 --> 00:01:41,520
all the necessary components are installed?

44
00:01:41,520 --> 00:01:43,080
And the answer is yes.

45
00:01:43,080 --> 00:01:45,450
It's one of the great things about DPKG

46
00:01:45,450 --> 00:01:47,460
is that it's going to go and find all the dependencies

47
00:01:47,460 --> 00:01:48,870
and install those for you

48
00:01:48,870 --> 00:01:52,710
when you're using DPKG with the -i option.

49
00:01:52,710 --> 00:01:55,020
Now, in addition to using DPKG,

50
00:01:55,020 --> 00:01:58,530
you can also use a newer version known as APT.

51
00:01:58,530 --> 00:02:01,230
Remember, DPKG was the original installer

52
00:02:01,230 --> 00:02:03,450
for Debian based Linux distributions

53
00:02:03,450 --> 00:02:07,260
but APT, instead is going to be a front end manager

54
00:02:07,260 --> 00:02:09,690
for that DPKG system.

55
00:02:09,690 --> 00:02:12,750
And much like yum is a front end manager for RPM

56
00:02:12,750 --> 00:02:14,820
inside of our Red Hat based distributions,

57
00:02:14,820 --> 00:02:18,780
we're going to use APT as a front end manager for DPKG

58
00:02:18,780 --> 00:02:20,790
on our Debian based systems.

59
00:02:20,790 --> 00:02:24,330
For a long time, APT actually used its commands

60
00:02:24,330 --> 00:02:26,250
by using a hyphenated scheme.

61
00:02:26,250 --> 00:02:29,100
So you might do things like apt-get

62
00:02:29,100 --> 00:02:32,910
or apt-cache to be able to interact with that system.

63
00:02:32,910 --> 00:02:35,130
Now there's a lot of different sub commands

64
00:02:35,130 --> 00:02:37,500
that are now added into APT as well.

65
00:02:37,500 --> 00:02:39,240
So if you want to install a package,

66
00:02:39,240 --> 00:02:42,780
you'll simply type apt install and the package name.

67
00:02:42,780 --> 00:02:44,880
This will install your packages.

68
00:02:44,880 --> 00:02:46,500
If you want to remove a package,

69
00:02:46,500 --> 00:02:49,920
you can then use apt remove and the package name

70
00:02:49,920 --> 00:02:51,660
to uninstall that package.

71
00:02:51,660 --> 00:02:54,150
Now, when you remove a package using APT,

72
00:02:54,150 --> 00:02:56,850
it does leave behind its configuration files.

73
00:02:56,850 --> 00:02:58,080
So this is important to know

74
00:02:58,080 --> 00:03:00,480
because if you go and reinstall that package later,

75
00:03:00,480 --> 00:03:03,660
a lot of those configurations will still be there for you.

76
00:03:03,660 --> 00:03:06,510
Another sub command we have is the purge sub command.

77
00:03:06,510 --> 00:03:10,200
You use this by typing apt purge and the package name

78
00:03:10,200 --> 00:03:11,370
to uninstall the package

79
00:03:11,370 --> 00:03:13,860
and remove its configuration files.

80
00:03:13,860 --> 00:03:15,990
If you want to get information about a package,

81
00:03:15,990 --> 00:03:19,050
you can type in apt show and the package name

82
00:03:19,050 --> 00:03:21,600
to report information about that package.

83
00:03:21,600 --> 00:03:23,280
If you want to know what version information

84
00:03:23,280 --> 00:03:24,990
you have on a particular package,

85
00:03:24,990 --> 00:03:28,170
you could type in apt version and the package name.

86
00:03:28,170 --> 00:03:31,050
The apt update sub command is one that we're going to use

87
00:03:31,050 --> 00:03:32,880
to update the APT database

88
00:03:32,880 --> 00:03:35,760
of the different available packages that we could install.

89
00:03:35,760 --> 00:03:37,800
And then if we use the upgrade sub command,

90
00:03:37,800 --> 00:03:40,770
we can type in apt upgrade and the package name

91
00:03:40,770 --> 00:03:42,870
to upgrade a particular software package

92
00:03:42,870 --> 00:03:44,400
to the latest version.

93
00:03:44,400 --> 00:03:45,420
If you want to upgrade

94
00:03:45,420 --> 00:03:47,940
all of your software packages to the latest version,

95
00:03:47,940 --> 00:03:51,420
you can do that by typing apt upgrade and hitting enter.

96
00:03:51,420 --> 00:03:53,370
By not specifying a package name,

97
00:03:53,370 --> 00:03:54,930
it tells the system you want to go ahead

98
00:03:54,930 --> 00:03:56,730
and upgrade all of them.

99
00:03:56,730 --> 00:04:00,270
To use APT, simply type in apt, the options,

100
00:04:00,270 --> 00:04:02,160
the sub command and the package name

101
00:04:02,160 --> 00:04:03,480
to be able to run APT

102
00:04:03,480 --> 00:04:05,310
and interact with the different packages

103
00:04:05,310 --> 00:04:07,320
using that package manager.

104
00:04:07,320 --> 00:04:09,480
Now, as I said, there were some other commands

105
00:04:09,480 --> 00:04:13,350
like apt-get, and apt-cache.

106
00:04:13,350 --> 00:04:15,300
These commands are still functional

107
00:04:15,300 --> 00:04:17,490
but they provide a lower level functionality

108
00:04:17,490 --> 00:04:19,769
and have more tight, specific controls

109
00:04:19,769 --> 00:04:23,820
than using the generic apt command with its sub commands.

110
00:04:23,820 --> 00:04:25,980
Now, these become a little bit more confusing

111
00:04:25,980 --> 00:04:28,560
because there's a lot of different options that you can do

112
00:04:28,560 --> 00:04:32,220
by using the apt get or apt cache command.

113
00:04:32,220 --> 00:04:34,230
Because of this, most people now rely

114
00:04:34,230 --> 00:04:36,750
on the newer variants of apt install

115
00:04:36,750 --> 00:04:40,470
or apt remove instead of using apt-get.

116
00:04:40,470 --> 00:04:42,810
The apt-cache is how you interact

117
00:04:42,810 --> 00:04:46,080
with the underlying database of the APT system.

118
00:04:46,080 --> 00:04:48,360
But again, you can do much of the same things

119
00:04:48,360 --> 00:04:50,490
using the other commands I just went through.

120
00:04:50,490 --> 00:04:53,580
For example, if you want to display package information,

121
00:04:53,580 --> 00:04:57,900
you used to be able to use apt-cache show package name,

122
00:04:57,900 --> 00:05:01,770
but now you can just use apt show package name

123
00:05:01,770 --> 00:05:03,690
and it will do the same thing.

124
00:05:03,690 --> 00:05:06,450
Now, the last thing I want to talk about in terms of APT

125
00:05:06,450 --> 00:05:08,700
is the difference between update and upgrade

126
00:05:08,700 --> 00:05:11,280
because a lot of people get this confused.

127
00:05:11,280 --> 00:05:13,530
The apt update command is going to be used

128
00:05:13,530 --> 00:05:17,130
to update the APT database of the available packages.

129
00:05:17,130 --> 00:05:18,990
This enables APT to become aware

130
00:05:18,990 --> 00:05:20,790
of any new versions of software

131
00:05:20,790 --> 00:05:22,680
that may now become available.

132
00:05:22,680 --> 00:05:24,990
For instance, if I ran one of these projects,

133
00:05:24,990 --> 00:05:26,970
I might have version 1.1 out.

134
00:05:26,970 --> 00:05:30,210
When I make a code update and this becomes version 1.2,

135
00:05:30,210 --> 00:05:32,580
I now can tell that to the APT system

136
00:05:32,580 --> 00:05:33,900
through the repositories,

137
00:05:33,900 --> 00:05:37,950
but your system won't know it until you do an APT update

138
00:05:37,950 --> 00:05:39,270
where it queries the database

139
00:05:39,270 --> 00:05:41,820
and says, give me all the latest information.

140
00:05:41,820 --> 00:05:43,110
Now, when we're looking at

141
00:05:43,110 --> 00:05:45,090
the upgrade option on the other hand,

142
00:05:45,090 --> 00:05:48,360
this is actually going to be used to install new software.

143
00:05:48,360 --> 00:05:53,100
Remember, apt update does not upgrade your software.

144
00:05:53,100 --> 00:05:55,200
It doesn't do anything to your own system

145
00:05:55,200 --> 00:05:57,870
except tell you what versions are now available.

146
00:05:57,870 --> 00:06:00,180
When you're using apt upgrade though,

147
00:06:00,180 --> 00:06:02,520
you're actually going and updating that software

148
00:06:02,520 --> 00:06:04,380
to the newer version that you just found

149
00:06:04,380 --> 00:06:06,540
inside the APT database.

150
00:06:06,540 --> 00:06:08,640
This is the full upgrade of the software

151
00:06:08,640 --> 00:06:11,430
and so we can actually download the latest version,

152
00:06:11,430 --> 00:06:12,600
install it on our system

153
00:06:12,600 --> 00:06:14,340
and use the new code and it's features

154
00:06:14,340 --> 00:06:16,080
that it's going to be installing.

155
00:06:16,080 --> 00:06:17,430
This is an important distinction

156
00:06:17,430 --> 00:06:18,480
that you should be aware of

157
00:06:18,480 --> 00:06:21,690
between apt update and apt upgrade.

158
00:06:21,690 --> 00:06:23,910
Now, that being said, as a best practice,

159
00:06:23,910 --> 00:06:26,340
whenever you're going to install a new piece of software,

160
00:06:26,340 --> 00:06:27,480
what should you do?

161
00:06:27,480 --> 00:06:31,110
Well, first, you should run apt update and hit enter.

162
00:06:31,110 --> 00:06:33,240
This will tell you what the latest version is.

163
00:06:33,240 --> 00:06:36,450
Then you should do apt upgrade and the package name

164
00:06:36,450 --> 00:06:38,010
to upgrade your specific package

165
00:06:38,010 --> 00:06:40,440
to that latest version that you just found.

166
00:06:40,440 --> 00:06:43,020
If you don't do the apt update first,

167
00:06:43,020 --> 00:06:45,720
you could be upgrading yourself to an older version

168
00:06:45,720 --> 00:06:47,640
and not the latest version that's available.

169
00:06:47,640 --> 00:06:48,630
So keep that in mind

170
00:06:48,630 --> 00:06:52,440
with differences between apt update and apt upgrade.

171
00:06:52,440 --> 00:06:54,510
And in general, always do an update

172
00:06:54,510 --> 00:06:55,953
before you do an upgrade.

