1
00:00:00,000 --> 00:00:14,460
Hey guys and welcome back.

2
00:00:14,460 --> 00:00:20,120
So in the previous nugget we had talked about the init tab file which is what the init process

3
00:00:20,120 --> 00:00:23,719
would originally consult when beginning to boot up.

4
00:00:23,719 --> 00:00:29,719
Within that nugget however we also mentioned the concept of some type of setup scripts.

5
00:00:29,719 --> 00:00:35,200
These are ultimately programs that run that will execute multiple commands or start multiple

6
00:00:35,200 --> 00:00:41,479
processes and for the purposes of the Lpik2 examination we have to understand what these

7
00:00:41,479 --> 00:00:47,840
boot scripts are and how they may differ depending on the type of distribution you have.

8
00:00:47,840 --> 00:00:53,719
Now one thing to mention when we're talking about this which is definitely relevant is

9
00:00:53,719 --> 00:00:56,439
how Cysfianet actually operates.

10
00:00:56,439 --> 00:01:03,199
So Cysfianet is not the most efficient way to start up your system and in fact this is

11
00:01:03,199 --> 00:01:08,319
one of the reasons why Cysfianet was ultimately replaced but the way it would operate it would

12
00:01:08,319 --> 00:01:10,840
operate any linear fashion.

13
00:01:10,840 --> 00:01:13,039
So what do I mean when I say linear?

14
00:01:13,039 --> 00:01:18,319
Well it would start the init process and it would tell if I could write correctly the

15
00:01:18,319 --> 00:01:19,319
init process.

16
00:01:19,319 --> 00:01:24,719
So that could be process number one and then after that was done it would begin process

17
00:01:25,200 --> 00:01:30,159
number two, whatever that may be and then process number three and then number four and then

18
00:01:30,159 --> 00:01:31,879
number five and then six.

19
00:01:31,879 --> 00:01:36,039
You kind of get the drift after number one had kicked off and done its thing.

20
00:01:36,039 --> 00:01:40,879
Number two followed and then number three and then number four, number five and when

21
00:01:40,879 --> 00:01:44,439
you happen to have lots of processes that have to be run.

22
00:01:44,439 --> 00:01:50,920
This is quite slow, quite sluggish and definitely inefficient so just something to be aware of.

23
00:01:50,920 --> 00:01:56,799
This is how the process actually happens when you're using a Cysfianet system.

24
00:01:56,799 --> 00:02:05,240
Now how does Cysfianet determine which processes to run and in which order i.e. what should

25
00:02:05,240 --> 00:02:11,960
I run and what should I run first and then second and then third and not just in some

26
00:02:11,960 --> 00:02:18,800
random order because of course certain processes rely on other processes so the order is indeed

27
00:02:18,800 --> 00:02:19,800
importance.

28
00:02:19,800 --> 00:02:24,240
So this is what we want to talk about primarily in this nugget right here.

29
00:02:24,240 --> 00:02:29,600
We have two different locations where init is going to look.

30
00:02:29,600 --> 00:02:35,120
If we happen to be looking on a red hat based distribution the location is going to be different

31
00:02:35,120 --> 00:02:39,720
than if we are looking on a Debian based distribution.

32
00:02:39,720 --> 00:02:45,880
So if you happen to be using a Debian based system the location where the init process

33
00:02:45,879 --> 00:02:52,319
is going to look is going to look in the exe directory and then the init.d directory.

34
00:02:52,319 --> 00:02:58,599
However if we happen to be using a red hat based system again we look in the exe directory

35
00:02:58,599 --> 00:03:04,800
but we then look in the rc.d file or rather rc.d directory my apologies.

36
00:03:04,800 --> 00:03:11,120
So let's talk about two important scripts that you would find on a red hat based system.

37
00:03:11,120 --> 00:03:15,319
So the first script I want to talk to you about is in the exe directory.

38
00:03:15,759 --> 00:03:21,280
It's going to be in rc.d because we're talking about red hat systems and the first script

39
00:03:21,280 --> 00:03:25,079
is going to be rc.sys init.

40
00:03:25,079 --> 00:03:30,519
What this one is all about it's designed to effectively load the system to a very simple

41
00:03:30,519 --> 00:03:36,719
state that is quite honestly the same as run level 1 a single user mode and all this script

42
00:03:36,719 --> 00:03:43,400
is going to do is going to perform actions such as mounting file systems and enabling

43
00:03:43,480 --> 00:03:50,719
devices such as RAID devices and logical volume manager and starting up some essential

44
00:03:50,719 --> 00:03:52,520
system services.

45
00:03:52,520 --> 00:03:58,200
Now for real world purposes this script right here happens to be what is known as a bash

46
00:03:58,200 --> 00:04:04,400
script i.e. it is written using the born again shell and you are very very unlikely to modify

47
00:04:04,400 --> 00:04:09,800
the contents of this bash script but as an administrator you may have to be able to look

48
00:04:09,880 --> 00:04:15,719
into this file and do a little bit of detective work in the event that you have some issues

49
00:04:15,719 --> 00:04:17,199
booting up your system.

50
00:04:17,199 --> 00:04:25,199
The next one again in the exe directory is going to be in rc.d and this one is just called

51
00:04:25,199 --> 00:04:26,199
rc.

52
00:04:26,199 --> 00:04:32,680
Now whenever we are on run levels 1 to 6 this script is going to be executed.

53
00:04:32,680 --> 00:04:38,920
Now this script itself will not do anything on its own you actually have to pass a particular

54
00:04:39,000 --> 00:04:44,199
value to this script such as 1 or such as 5.

55
00:04:44,199 --> 00:04:48,199
Recall what we saw in the init tab file in the previous nugget.

56
00:04:48,199 --> 00:04:52,400
Within this file here this is where you would specify a particular argument.

57
00:04:52,400 --> 00:04:59,120
Now what this actually means say for example we had l3 which would be the id and then run

58
00:04:59,120 --> 00:05:08,120
level 5 and then the weights action and then we could specify exe rc.d.rc and then we could

59
00:05:09,000 --> 00:05:11,520
provide an argument number 5.

60
00:05:11,520 --> 00:05:14,879
We are basically giving the argument 5 to this script.

61
00:05:14,879 --> 00:05:19,600
For run level 5 we are going to use the weights action i.e. allow it to complete and this

62
00:05:19,600 --> 00:05:25,879
script is ultimately going to find additional script to help us load into the correct specified

63
00:05:25,879 --> 00:05:29,600
run level in this case here run level 5.

64
00:05:29,600 --> 00:05:34,360
We will actually find directories within this directory and it is going to follow a very

65
00:05:34,360 --> 00:05:35,639
particular format.

66
00:05:35,639 --> 00:05:46,560
The format would look something like say this rc0.d and rc1.d and maybe rc5.d get the drift.

67
00:05:46,560 --> 00:05:52,759
These are directories which actually correlate to a particular run level i.e. within this

68
00:05:52,759 --> 00:05:58,800
directory here this would be files relating to run level 0 whereas in rc5.d this would

69
00:05:58,800 --> 00:06:02,240
be a directory for run level 5.

70
00:06:02,240 --> 00:06:08,240
Now within these directories what you are going to find are symbolic links.

71
00:06:08,240 --> 00:06:14,720
Now these symbolic links ultimately relate to the starting of processes as well as the

72
00:06:14,720 --> 00:06:19,600
killing of processes which might sound a little bit dramatic but ultimately starting processes

73
00:06:19,600 --> 00:06:21,079
and stopping processes.

74
00:06:21,079 --> 00:06:27,439
Now these symbolic links are going to follow a very particular format.

75
00:06:27,439 --> 00:06:33,279
If the symbolic link happens to begin with an s then this is going to point to a process

76
00:06:33,279 --> 00:06:40,240
relating to starting a process and if the symbolic link begins with a k you can guess

77
00:06:40,240 --> 00:06:43,600
this actually relates to killing processes.

78
00:06:43,600 --> 00:06:49,360
So all these symbolic links do is they point to scripts and these scripts handle these

79
00:06:49,360 --> 00:06:52,800
tasks i.e. starting things or stopping things.

80
00:06:52,800 --> 00:06:59,000
But if we happen to see a symbolic link which was k and then maybe the number 9 and then

81
00:06:59,000 --> 00:07:06,240
maybe i don't know nginx we can infer by the formatting of this symbolic link of what it's

82
00:07:06,240 --> 00:07:12,319
actually doing we see a k so we know this sim link is pointing to a script which is going

83
00:07:12,319 --> 00:07:14,920
to kill a particular process.

84
00:07:14,920 --> 00:07:19,960
We get the number here which is the numerical number remember 6 feet and it operates in

85
00:07:19,959 --> 00:07:21,839
a sequential manner.

86
00:07:21,839 --> 00:07:27,359
Process 1 will go before process 2 in this case here we have process 9 so after process

87
00:07:27,359 --> 00:07:34,379
8 begins this particular one will execute and it's going to kill the nginx process.

88
00:07:34,379 --> 00:07:40,839
So like i say on modern systems the sysv init program is ultimately outdated and has been

89
00:07:40,839 --> 00:07:45,959
replaced with system d but nevertheless we can get a rough idea of what this looks like

90
00:07:45,959 --> 00:07:50,639
even on a modern system so what i'll do is i'll go into the etsy directory and if i happen

91
00:07:50,639 --> 00:08:00,000
to go into maybe say rc3.d what this is is scripts relating to run level 3 whereas if

92
00:08:00,000 --> 00:08:08,120
i happen to go in let's say rc5.d this would be scripts relating to run level 5 now if

93
00:08:08,120 --> 00:08:14,039
i do an ls we can just see a whole bunch of water sim links if i do an ls-l for the long

94
00:08:14,040 --> 00:08:19,360
listing we can actually see where these sim links are pointing to now notice because this

95
00:08:19,360 --> 00:08:25,240
is a debian based system these are actually pointing to init.d whereas this would be different

96
00:08:25,240 --> 00:08:27,560
within a red hat based system.

97
00:08:27,560 --> 00:08:33,879
Now notice we have the value k this means that this is relating to killing processes

98
00:08:33,879 --> 00:08:38,639
whereas the other ones here these are all beginning with s these are for starting processes

99
00:08:38,639 --> 00:08:43,519
and the next one is the value the process number now you might notice that these all appear

100
00:08:43,519 --> 00:08:49,240
to be starting at the same time we are now on a modern system debaist system and things

101
00:08:49,240 --> 00:08:55,039
can actually operate in parallel so we're no longer hamstrung by the older implementation

102
00:08:55,039 --> 00:08:59,919
of sysvian.net so that is what i'm saying that the example here is not exactly perfect

103
00:08:59,919 --> 00:09:04,720
because we are talking about older outdated technology which frustratingly is still a

104
00:09:04,720 --> 00:09:09,120
big part of the lpik 2 examination of course but that is what you're seeing when you see

105
00:09:09,120 --> 00:09:14,679
these discrepancies we are ultimately mapping old technology onto new technology so if i

106
00:09:14,679 --> 00:09:23,440
happen to open up one of these scripts right here so i'll say nano s01 acpid and hit enter

107
00:09:23,440 --> 00:09:29,120
what you are looking at here is a bash script this is ultimately just a file full of programming

108
00:09:29,120 --> 00:09:34,879
logic to do certain things such as loading particular modules and starting and stopping

109
00:09:34,879 --> 00:09:40,960
particular processes so on and so forth and ultimately this is what all of these files

110
00:09:40,960 --> 00:09:47,559
look like they're all bash scripts again we go into maybe say s1 cron same type of deal

111
00:09:47,559 --> 00:09:53,519
we are just running a script to stand up the cron service a whole bunch of programming

112
00:09:53,519 --> 00:10:00,480
logic within here now if we wanted to control a particular action maybe we wanted to change

113
00:10:00,480 --> 00:10:06,560
the rsync from starting up what we could actually do is we could rename the sim link now the

114
00:10:06,560 --> 00:10:15,000
sim link happens to be s01 rsync what if we happen to change that so i said s01 rsync

115
00:10:15,000 --> 00:10:20,720
and i changed it to k01 rsync what i need to do of course is to do super user privileges

116
00:10:20,720 --> 00:10:27,120
because i'm in the etsy directory let me just type in my passwords and now if i do an ls-l

117
00:10:27,120 --> 00:10:33,039
we can see here rsync has a sim link beginning with k so what this means is that when we

118
00:10:33,039 --> 00:10:38,000
happen to drop into our particular run level this is run level 5 instead of starting the

119
00:10:38,000 --> 00:10:43,519
rsync program we would happen to stop it now the issue is here is that whilst we can manage

120
00:10:43,519 --> 00:10:49,440
these processes we can ultimately invoke scripts to start or to kill particular applications

121
00:10:49,440 --> 00:10:55,080
and actions this is not the most friendly way to manage such a thing just by renaming sim

122
00:10:55,120 --> 00:11:01,000
links things can be confusing and by the way on older systems whereby we had to use this

123
00:11:01,000 --> 00:11:07,160
particular action i.e. when we were using sys the init-based systems whereby the processes

124
00:11:07,160 --> 00:11:13,000
were not parallel they were sequential and the order of operations mattered much much more

125
00:11:13,000 --> 00:11:19,160
by renaming sim links if we happen to maybe use the wrong number we could actually change the

126
00:11:19,160 --> 00:11:25,000
order of operations and if some processes relied on another process standing up and we got

127
00:11:25,000 --> 00:11:30,679
the order wrong then well we could definitely cause some issues but the good news was for system

128
00:11:30,679 --> 00:11:37,399
the based administrators they did actually have the ability to use some particular tools to simplify

129
00:11:37,399 --> 00:11:41,480
this action now what exactly were those tools how were they used well that's what we're going to be

130
00:11:41,480 --> 00:11:45,960
talking about in the very next nugget so i hope this has been informative for you and i'd like to

131
00:11:45,960 --> 00:11:47,960
thank you for viewing

