SysVinit chkconfig

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 there Cybrarians.
00:00
Welcome back to the Linux+ course here at Cybrary,
00:00
I'm your instructor Rob Goelz.
00:00
In today's lesson, we're going to be talking about
00:00
SysVinit and using the chkconfig command.
00:00
Upon completion of this lesson,
00:00
you are going to be able to explain
00:00
the purpose of the chkconfig.
00:00
We're going to see how to chkconfig is
00:00
used in SysVinit and with
00:00
the System V and we're going to
00:00
use the chkconfig command.
00:00
In SysVinit, chkconfig command
00:00
manages service run levels.
00:00
Basically which services startup at
00:00
boot time while
00:00
the service command manages service state.
00:00
By comparison in system D,
00:00
system CTL does both,
00:00
we can manage both service and run levels,
00:00
we can set up and enable
00:00
the services to run and we can
00:00
start them using system CTL.
00:00
But in System V, we
00:00
actually have to use two different commands.
00:00
Let's go ahead and take a look at
00:00
the chkconfig with some demo time.
00:00
Here we are back in
00:00
our CentOS environment and we're in CentOS 6.
00:00
This is an older distro that runs
00:00
System V. What we can do here
00:00
is get back to you at
00:00
the CNET D factory there if we see we're in at CNET.
00:00
D by running a present working directory,
00:00
and then let's take a look at the file again for SSHD.
00:00
Now what we're going to see in this SSHD is this line,
00:00
check config 2345,
00:00
which tells us in
00:00
the chkconfig statement which
00:00
run levels of service we'll start with by default.
00:00
In other words, the service will come
00:00
up with any of these specified run levels,
00:00
while the system is starting in 2345.
00:00
Those are just generally going to
00:00
be either multi-user environments,
00:00
a single user environment with no graphics,
00:00
or a graphical environment.
00:00
Let's go ahead and quit out of this file here.
00:00
Let's actually take a look at something else.
00:00
Just as we talked about
00:00
the service command in the previous lesson,
00:00
and the service command being
00:00
a wrapper for changing service state in CSV,
00:00
the check config command is
00:00
a wrapper for changing service run levels.
00:00
We could do a few things with check config.
00:00
For instance if we want to just see all of
00:00
the run levels for a specific service,
00:00
we can do check the config list on SSHD.
00:00
Just as I said when we looked at the list in the file,
00:00
we see 2, 3, 4,
00:00
and 5 are the run levels
00:00
that this is set up to start with by default.
00:00
If we wanted to enable
00:00
the service to start from our current run level,
00:00
we could do that with Sudo chkconfig SSHD on,
00:00
and it'll set it up to run from our current run level.
00:00
If we wanted to turn it off,
00:00
we could do Sudo chkconfig SSHD off,
00:00
and then we'll turn it off from our current run level.
00:00
Now actually, since we've done that,
00:00
we're going to see if we just do a chkconfig list SSHD,
00:00
we'll see that it's off for all of their own levels.
00:00
Let's go ahead and specify it to
00:00
run on only specific run levels.
00:00
For instance, if we know in this system we're only ever
00:00
going to use run level 3 and five,
00:00
which are multi-user and graphical targets respectively,
00:00
we can tell chkconfig, hey,
00:00
just run it in [inaudible] don't ever state it otherwise.
00:00
So Sudo chkconfig - - levels,
00:00
and now we say 35 SSHD,
00:00
because that's the service we want to start,
00:00
and we want to set it as on.
00:00
Now when we run the check config list for SSHD,
00:00
we said it's only on for Level 3 and Level 5.
00:00
Now if we wanted to completely
00:00
remove this from ever starting,
00:00
what we do if we were to mask a service in system D,
00:00
we can do a chkconfig,
00:00
and then instead of list here we change
00:00
this to say Del for delete.
00:00
So Sudo chkconfig Del SSHD,
00:00
and now if we do a chkconfig list
00:00
for SSHD it says, hey,
00:00
SSV supports chkconfig,
00:00
bu it's not a reference, we don't have it anywhere.
00:00
In order to get it back to the state that
00:00
it was in before we started messing with it,
00:00
we actually have to run the ad command.
00:00
If you do a Sudo check config ad on SSHD,
00:00
and now we do another check config list SSHD,
00:00
we see it's back in the state that
00:00
it was before we get started,
00:00
where it's set up for 2, 3, 4, and 5.
00:00
But with that, we've reached the end of this lesson.
00:00
In this lesson, we covered the purpose of chkconfig,
00:00
we talked about how chkconfig
00:00
works in System 5 and SysVinit,
00:00
and how to use the chkconfig command.
00:00
Thanks so much for being here and I look
00:00
forward to seeing you at our next lesson.
Up Next