Hey guys and welcome back. So in the previous nugget I got ahead of myself and we're not
exactly going to look at the boot scripts quite just yet. In fact what we're briefly
going to look at is how we can manually change and set the run levels via the command line
ourselves. So the command that we're going to be looking at or should I say the commands
is going to be the init command as well as the tell init command. Now these commands
like I say are based on sysv init therefore they are deprecated in modern systems. So
these two commands whilst we can actually issue them on modern system d based systems
like I say they are deprecated we are just exploring them for the purposes of the examination.
So the first command here is the init command we know this is the init process and tell init
is the other option. Now the first thing I will say is that both of these commands will
work and both will ultimately do the same thing. However it is an accepted best practice
to use the tell init command so whilst you can get away with actually typing init it
is not the recommended way to handle this process. So the first thing I'm going to do
is I'm going to show you one command which can identify to us the current run level we
are using so what I will do here is I will just full screen this and the command that
we can use to identify the current run level as well as the previous run level the system
is using is quite simply the run level command if I just hit enter we can see the value n
and then the value 5 now we are seeing the value n because previously the system was
shut down and the value on the right here is the current run level so we see run level
5 we talked about what run level 5 happens to be this is a multi user mode it has networking
and of course as we can see here we have the graphical user interface so we can click about
all the icons we can drag and drop so on so forth so if I want to modify this particular
run level I've got two options like I say I can say init and then specify a run level
such as run level 0 which we know is the value to shut down but like I say we want to be
using the tell init command so what I could do here is I could say tell init and I could
change it to maybe say run level 3 now you may recall if we do tell init 3 I'm going
to have to type in my passwords and to enter oh looks like I typed in the wrong password
try this again there we go now we're going to reload we will lose our graphical user
interface and we will ultimately drop into multi user mode without the graphical user
interface now because of virtual box what we're doing is experiencing a little bit of a problem
if I press control alt and F1 we should actually see our login page so we can see here ipv0
login type in my username and my password to enter and notice now I have my Linux terminal
but I no longer have a graphical user interface this would be a very common setting for a
server very low on resources no real demands and a much smaller attack surface however
like I say if we actually run the run level command we can now see even though it's pretty
small the current run level on the right is the value 3 and the one on the left was the
one that was before the value 5 so if we want to restore the system to be the way it was
before we can say tell init 5 if I hit enter and in this case we have to use support user
privileges also tell init 5 with the sudo command have to type in the old password there we go
and try again now we're going to reload and we are presented again with our graphical user
interface and we can go back in login got to the top here I'll go into my terminal emulator
I will say run level and now this is inverted once again the current level is 5 the previous
one was 3 now like I say we can also use the init command even though it is not recommended
if I said init 6 we know this would be the run level for a reboot if I just hit enter
now we're going to reboot the system is beginning to reload just give it a little minute or
two and the system has rebooted let me just log in type in my password there we go and
now we are back if I click my icon up here go to my terminal emulator I say run level
we can see we have the value n again because the system was rebooted and our current run
level again is 5 and again if we wanted to shut down the system I could use the command
tell init and what would be the run level to shut down the system or to halt the system
as the terminology goes we can use run level 0 so if we hit enter it will shut down the
system and it will fully close so we can use these commands the init command or the tell
init command to ultimately perform these tasks by specifying a particular run level i.e.
0 all the way through to 6 but the recommended way is to use the tell init command the way
I like to remember this is by thinking that you are telling the init process what run
level to actually use and if we want to verify our current run level and the previous run
level we do also have that run level command ok doc so that is us for being able to manually
change the run level of our system now let's begin to talk about these boot scripts and
that's what we will be doing in the very next nuggets i hope this has been informative for
you and i'd like to thank you for viewing