1
00:00:00,050 --> 00:00:00,990
In this lesson,

2
00:00:00,990 --> 00:00:02,790
we're going to discuss repositories,

3
00:00:02,790 --> 00:00:05,400
because most of the software packages that you're going to use

4
00:00:05,400 --> 00:00:08,340
are going to be acquired from those repositories.

5
00:00:08,340 --> 00:00:09,360
Now, most packages

6
00:00:09,360 --> 00:00:12,210
are included in the official distribution repositories,

7
00:00:12,210 --> 00:00:15,120
but there's also cases where packages can't be installed

8
00:00:15,120 --> 00:00:16,320
due to dependencies,

9
00:00:16,320 --> 00:00:17,340
and you're going to need to install

10
00:00:17,340 --> 00:00:19,050
all the dependencies manually,

11
00:00:19,050 --> 00:00:21,060
so you may have to create your own repository

12
00:00:21,060 --> 00:00:23,130
and deploy your packages from it.

13
00:00:23,130 --> 00:00:25,080
Knowing which repositories you're using

14
00:00:25,080 --> 00:00:26,610
can also help you understand

15
00:00:26,610 --> 00:00:28,740
how your system is managing its updates.

16
00:00:28,740 --> 00:00:32,040
So let's go ahead and discuss how you configure repositories

17
00:00:32,040 --> 00:00:35,680
using various local command line tools to meet your needs.

18
00:00:35,680 --> 00:00:38,010
Repositories, also known as repos,

19
00:00:38,010 --> 00:00:41,220
are storage locations for available software packages.

20
00:00:41,220 --> 00:00:43,530
Now, repositories are checked by package managers,

21
00:00:43,530 --> 00:00:45,900
like YUM, DNF, and APT,

22
00:00:45,900 --> 00:00:48,570
whenever you're installing or upgrading software.

23
00:00:48,570 --> 00:00:50,520
There are three kinds of repositories

24
00:00:50,520 --> 00:00:51,660
that you're going to find.

25
00:00:51,660 --> 00:00:53,520
These are local repositories,

26
00:00:53,520 --> 00:00:57,450
centralized internal repositories, and vendor repositories.

27
00:00:57,450 --> 00:00:58,590
Local repositories

28
00:00:58,590 --> 00:01:01,290
are stored on the system's local storage drive.

29
00:01:01,290 --> 00:01:02,610
Installation is easy,

30
00:01:02,610 --> 00:01:05,220
but version control is much more difficult

31
00:01:05,220 --> 00:01:06,870
because of the decentralized nature

32
00:01:06,870 --> 00:01:08,880
of these local repositories.

33
00:01:08,880 --> 00:01:11,400
If you manage 20 Linux servers, for example,

34
00:01:11,400 --> 00:01:13,230
each one is going to have its own repository

35
00:01:13,230 --> 00:01:14,910
that you have to maintain.

36
00:01:14,910 --> 00:01:17,070
Instead, you might move to a centralized

37
00:01:17,070 --> 00:01:18,750
internal repository.

38
00:01:18,750 --> 00:01:20,700
These centralized internal repositories

39
00:01:20,700 --> 00:01:22,650
are stored on one or more systems

40
00:01:22,650 --> 00:01:24,870
within your internal local area network,

41
00:01:24,870 --> 00:01:27,630
and they're managed by a Linux system administrator.

42
00:01:27,630 --> 00:01:30,900
This centralized approach makes version control much simpler

43
00:01:30,900 --> 00:01:32,490
across your organization.

44
00:01:32,490 --> 00:01:35,520
So again, let's say you're managing 20 Linux servers,

45
00:01:35,520 --> 00:01:39,540
one can host all the repositories for all the other 19.

46
00:01:39,540 --> 00:01:42,720
This way, that one server is your central repository

47
00:01:42,720 --> 00:01:44,730
internal to your own local area network,

48
00:01:44,730 --> 00:01:47,460
and all of your Linux servers will go to that server

49
00:01:47,460 --> 00:01:49,500
to download their packages from it.

50
00:01:49,500 --> 00:01:52,890
Now, the third type we have is known as a vendor repository.

51
00:01:52,890 --> 00:01:54,660
These are maintained on the internet,

52
00:01:54,660 --> 00:01:57,420
often by the distribution vendor themself.

53
00:01:57,420 --> 00:01:59,910
Version control here is very difficult though,

54
00:01:59,910 --> 00:02:01,470
because the vendor gets to decide

55
00:02:01,470 --> 00:02:03,810
what package versions are being made available

56
00:02:03,810 --> 00:02:08,070
to everyone in the world inside of their vendor repository.

57
00:02:08,070 --> 00:02:10,620
Therefore, if you're working as a Linux system administrator

58
00:02:10,620 --> 00:02:13,050
on an enterprise network, most of the time,

59
00:02:13,050 --> 00:02:14,820
you're going to find that you're using a centralized

60
00:02:14,820 --> 00:02:16,290
internal repository.

61
00:02:16,290 --> 00:02:17,460
That way, you can control

62
00:02:17,460 --> 00:02:19,590
exactly what versions are being used

63
00:02:19,590 --> 00:02:21,750
on all of your Linux servers.

64
00:02:21,750 --> 00:02:23,850
Now, system administrators can also designate

65
00:02:23,850 --> 00:02:26,850
a specific location as a yum repository

66
00:02:26,850 --> 00:02:29,400
to be able to create this internal repository.

67
00:02:29,400 --> 00:02:32,910
To do this, you're going to use the createrepo command.

68
00:02:32,910 --> 00:02:35,250
This command is going to update the XML files

69
00:02:35,250 --> 00:02:38,100
that are used to reference the repository's location.

70
00:02:38,100 --> 00:02:41,040
This repository might be on the local storage drive,

71
00:02:41,040 --> 00:02:42,870
which is going to be a local repository,

72
00:02:42,870 --> 00:02:45,870
or it could be available from an Apache web server,

73
00:02:45,870 --> 00:02:48,990
which becomes a centralized internal repository.

74
00:02:48,990 --> 00:02:51,240
After running the createrepo command,

75
00:02:51,240 --> 00:02:55,440
a .repo or repo configuration file is going to be created

76
00:02:55,440 --> 00:02:57,150
and that provides additional information

77
00:02:57,150 --> 00:02:58,860
about your repository.

78
00:02:58,860 --> 00:03:00,960
The .repo files are going to be stored

79
00:03:00,960 --> 00:03:05,910
in the /etc/yum.repos.d/ directory.

80
00:03:05,910 --> 00:03:08,190
Some of the components of the .repo file

81
00:03:08,190 --> 00:03:11,250
include the bracket repo-name bracket,

82
00:03:11,250 --> 00:03:13,650
which is going to refer to the repository name.

83
00:03:13,650 --> 00:03:15,570
name=Repository Name,

84
00:03:15,570 --> 00:03:18,330
which refers to the human-friendly name of that repo.

85
00:03:18,330 --> 00:03:21,960
baseurl=, which refers to the path to the repo.

86
00:03:21,960 --> 00:03:25,200
enabled=1, which basically enables the repo.

87
00:03:25,200 --> 00:03:27,780
If you set this to zero, it will disable the repo.

88
00:03:27,780 --> 00:03:32,460
And gpgcheck=0, which disables GPG checking,

89
00:03:32,460 --> 00:03:34,890
which is a form of encryption in digital certificates.

90
00:03:34,890 --> 00:03:37,650
If you want to enable this, you could set this to one.

91
00:03:37,650 --> 00:03:39,780
Another yum repository configuration file

92
00:03:39,780 --> 00:03:43,410
is located at /etc/yum.conf,

93
00:03:43,410 --> 00:03:44,430
so you should also look at that

94
00:03:44,430 --> 00:03:46,410
to ensure it's configured correctly.

95
00:03:46,410 --> 00:03:48,630
If you're using DNF as your package manager,

96
00:03:48,630 --> 00:03:53,400
you should also check the /etc/dnf/dnf.conf file,

97
00:03:53,400 --> 00:03:54,990
because it contains the configurations

98
00:03:54,990 --> 00:03:57,720
for your repositories when using DNF.

99
00:03:57,720 --> 00:03:58,800
Now, the yum command

100
00:03:58,800 --> 00:04:00,690
also includes some additional sub commands

101
00:04:00,690 --> 00:04:03,150
for viewing and using repositories.

102
00:04:03,150 --> 00:04:06,390
If you use yum repolist, this is going to be used

103
00:04:06,390 --> 00:04:08,670
to see all of the available repositories.

104
00:04:08,670 --> 00:04:10,920
If you use yum makecache,

105
00:04:10,920 --> 00:04:13,050
this is going to be used to locally cache information

106
00:04:13,050 --> 00:04:15,150
about the available repositories.

107
00:04:15,150 --> 00:04:17,339
And if you use yum clean all,

108
00:04:17,339 --> 00:04:18,390
this command is going to be used

109
00:04:18,390 --> 00:04:20,760
to clear all the out-of-date cache information

110
00:04:20,760 --> 00:04:22,860
so you can download a new copy.

111
00:04:22,860 --> 00:04:24,780
Yum also enables the synchronization

112
00:04:24,780 --> 00:04:28,020
of an online repository to a local storage location too,

113
00:04:28,020 --> 00:04:29,280
if you want to.

114
00:04:29,280 --> 00:04:30,990
This is known as mirroring,

115
00:04:30,990 --> 00:04:33,390
and it has the advantage of reducing the way-in traffic

116
00:04:33,390 --> 00:04:35,010
and lessening the time to load things

117
00:04:35,010 --> 00:04:37,110
from the parent repository.

118
00:04:37,110 --> 00:04:39,960
This is done by using the reposync utility.

119
00:04:39,960 --> 00:04:41,940
The reposync utility is going to be used

120
00:04:41,940 --> 00:04:44,280
to manage this synchronization process,

121
00:04:44,280 --> 00:04:45,600
and you can choose to synchronize

122
00:04:45,600 --> 00:04:47,400
the parent repository once,

123
00:04:47,400 --> 00:04:50,100
or you can cause it to update periodically.

124
00:04:50,100 --> 00:04:52,470
For example, you as a system administrator

125
00:04:52,470 --> 00:04:54,960
might want to synchronize the Red Hat Network

126
00:04:54,960 --> 00:04:59,220
or RHN repository over to a local server that you control.

127
00:04:59,220 --> 00:05:01,440
This then enables internal Red Hat servers

128
00:05:01,440 --> 00:05:03,780
to use the local server as a repository,

129
00:05:03,780 --> 00:05:05,400
instead of having to go over the internet

130
00:05:05,400 --> 00:05:08,340
to the Red Hat Networks repository itself.

131
00:05:08,340 --> 00:05:11,130
To do this, simply run the reposync command

132
00:05:11,130 --> 00:05:14,010
by typing reposync and the options.

133
00:05:14,010 --> 00:05:15,570
Like the yum package manager,

134
00:05:15,570 --> 00:05:18,300
the APT package manager can also be configured

135
00:05:18,300 --> 00:05:19,500
to access repositories

136
00:05:19,500 --> 00:05:21,870
as part of the software management life cycle.

137
00:05:21,870 --> 00:05:24,990
The repositories are going to be configured for APT

138
00:05:24,990 --> 00:05:29,990
inside the /etc/apt/sources.list file,

139
00:05:30,390 --> 00:05:35,390
and in the /etc/apt/sources.list.d/ directory.

140
00:05:37,230 --> 00:05:40,140
Like the yum repositories, APT repositories

141
00:05:40,140 --> 00:05:42,630
are also going to be able to be on the local system,

142
00:05:42,630 --> 00:05:43,800
on a local network,

143
00:05:43,800 --> 00:05:46,980
or hosted on the internet by a vendor.

144
00:05:46,980 --> 00:05:49,800
When it comes to configuring your APT package manager,

145
00:05:49,800 --> 00:05:52,200
you do want to check the configuration files for that

146
00:05:52,200 --> 00:05:55,560
under /etc/apt.conf,

147
00:05:55,560 --> 00:05:57,150
which contains the configuration file

148
00:05:57,150 --> 00:05:58,833
for your APT package manager.

