SysVinit runlevels

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hey, Cybrarians.
00:00
>> Welcome back to
00:00
>> the Linux Plus course here at Cybrary.
00:00
I'm your instructor Rob Goelz.
00:00
In today's lesson, we're going to be
00:00
covering system V runlevels.
00:00
Upon completion of today's lesson,
00:00
you are going to understand the purpose of
00:00
runlevels in system V or with SysVinit,
00:00
we're going to talk about the different runlevels
00:00
that are used and
00:00
how SysVinit interacts with /etc/inittab,
00:00
rc.d, and rc.local.
00:00
Then finally, we'll see how we can use the init or
00:00
telinit command to change runlevels.
00:00
In system V, a runlevel indicates
00:00
a system states such as a multi-user environment,
00:00
a graphical environment, or a rescue shell.
00:00
This runlevel is used by the init process to determine
00:00
what services or resources are available at that state.
00:00
In other words, if you come
00:00
up in a multi-user environment,
00:00
do you need a graphical environment?
00:00
No, you don't need a graphics,
00:00
you don't need a display manager,
00:00
it's just a multi-user environment with a shell.
00:00
Really all of these runlevels are just sets
00:00
of services that are grouped to run together.
00:00
Runlevel 0, and we can compare these to systemd.
00:00
Just like when we were looking at systemd,
00:00
we compared it against SysV.
00:00
Runlevel 0, shuts down the system.
00:00
In systemd, that would be the poweroff.target.
00:00
Runlevel 1 configures a rescue shell,
00:00
that's the rescue.target in systemd.
00:00
Then runlevel 2 is a non-graphical
00:00
multi-user environment with networking disable.
00:00
There's not really an equivalent for that in the systemd.
00:00
Runlevel 3 is a non-graphical multi-user environment
00:00
with networking enabled,
00:00
and that is the multiuser target in systemd,
00:00
that's where you come up with no graphics,
00:00
but just a shell.
00:00
Now runlevel 4 is something that is
00:00
here in system V and SysVinit,
00:00
but it's unused in systemd.
00:00
Runlevel 5 is our graphic multi-user environment,
00:00
that's the graphical target in systemd.
00:00
Then finally runlevel 6,
00:00
reboots the system, that's the reboot target in systemd.
00:00
Now let's step back for a minute and think about this.
00:00
We're at the initialization phase.
00:00
How does this system know which runlevel
00:00
to initialize with when we're talking about System V?
00:00
Well, it uses /etc/inittab.
00:00
The inittab is actually a script,
00:00
and this script points to runlevel scripts and
00:00
those runlevel scripts define which scripts be
00:00
executed for each runlevel.
00:00
/etc/inittab defines the scripts
00:00
to be executed at each runlevel.
00:00
Well, where are those scripts stored?
00:00
Well, the runlevel scripts are stored in /etc/rc.d,
00:00
that directory, and
00:00
there's directories for each runlevel.
00:00
We can see those on the right-hand side,
00:00
rc 0 through six.
00:00
Then the scripts themselves have an S or a K to
00:00
indicate what happens to
00:00
other services that start at this runlevel.
00:00
If the script has an S in front of the service,
00:00
that means that the service gets
00:00
started when you go into this runlevel.
00:00
But if the service has a K in front of it,
00:00
when you go into this run level,
00:00
it's going to kill that service,
00:00
it's going to stop that service from running.
00:00
Really this is just the way that it specifies
00:00
which services start under the runlevel,
00:00
and which services are stopped or
00:00
killed when transferring it into that runlevel.
00:00
Now, the rc.local file is
00:00
another script and its purpose is to run at boot or
00:00
whenever you change boot levels
00:00
because it's going to contain
00:00
the commands that are going to run
00:00
after you boot or
00:00
after you change into a different runlevel.
00:00
Speaking of changing runlevels, how do you do that?
00:00
Well, if you were in systemd,
00:00
we saw how we could do that.
00:00
We could change to a different run level
00:00
called a target in
00:00
systemd with the command system CTL isolate,
00:00
and then the target that we want to go to.
00:00
But how do you change runlevels in SysVinit?
00:00
Well, you use the init or the telinit command,
00:00
and really all that does is it calls
00:00
the script /etc/rc.d/rc,
00:00
and it only takes a one parameter,
00:00
and that's the runlevel number.
00:00
Then what happens is it runs the kill scripts and
00:00
start scripts in that runlevel directory that we saw,
00:00
to determine which services
00:00
start and which services get
00:00
killed when you go into that runlevel.
00:00
But with that, we've reached the end of this lesson.
00:00
In this lesson we covered
00:00
the purposes of runlevels in SysVinit,
00:00
we talked about the definitions of the runlevels 0-6.
00:00
We also talked about how SysVinit
00:00
interacts with runlevels looking
00:00
at /etc/inittab, /etc/rc.d and /etc/rclocal.
00:00
Then finally we talked about changing
00:00
runlevels with init and telinit.
00:00
Thanks so much for being here and I look
00:00
forward to seeing you in our next lesson.
Up Next