< Return to Video

CompTIA Linux+: Managing Services #11

  • 0:03 - 0:06
    you're watching it pro tv
  • 0:06 - 0:08
    hello thank you for watching it pro tv
  • 0:08 - 0:10
    helping you level up with it learning
  • 0:10 - 0:12
    everywhere you go i'm zach mimis your
  • 0:12 - 0:14
    host for this episode of comtea linux
  • 0:14 - 0:17
    plus and in this episode managing
  • 0:17 - 0:19
    services with system d
  • 0:19 - 0:21
    and we've asked our expert don bissett
  • 0:21 - 0:22
    to tell us more don good to see you
  • 0:22 - 0:24
    thank you for being here glad to be here
  • 0:24 - 0:25
    zach i'm ready to dive into the world of
  • 0:25 - 0:28
    system d which is a a really powerful
  • 0:28 - 0:30
    new technology i'm gonna say new it's
  • 0:30 - 0:32
    actually been around since i think 2008
  • 0:32 - 0:33
    but really gained prominence in the last
  • 0:33 - 0:36
    five to six years uh it is responsible
  • 0:36 - 0:38
    for powering the majority of linux
  • 0:38 - 0:40
    distros that are out there so really
  • 0:40 - 0:41
    important that we need to learn how it
  • 0:41 - 0:43
    works what it does and because
  • 0:43 - 0:44
    everything it's doing is behind the
  • 0:44 - 0:46
    scenes so in this episode what we're
  • 0:46 - 0:47
    going to do is kind of pull back the
  • 0:47 - 0:49
    curtain and get a chance to see exactly
  • 0:49 - 0:52
    what systemd is like how it functions
  • 0:52 - 0:53
    how we can interact with it to keep our
  • 0:53 - 0:55
    system up and running and make sure our
  • 0:55 - 0:56
    services are operating properly well how
  • 0:56 - 0:59
    are services controlled under linux
  • 0:59 - 1:01
    so you know there's a few different ways
  • 1:01 - 1:03
    this stuff can be controlled and we're
  • 1:03 - 1:05
    going to focus on systemd but it's not
  • 1:05 - 1:06
    the only way so that there's many
  • 1:06 - 1:09
    systems that use the original unix init
  • 1:09 - 1:11
    system so you know when linux boots up
  • 1:11 - 1:12
    there's a kernel right and the linux
  • 1:12 - 1:13
    kernel gets called that's really
  • 1:13 - 1:15
    important that's the part that linus
  • 1:15 - 1:18
    torvalds wrote but the kernel itself
  • 1:18 - 1:20
    doesn't interact with the user much it's
  • 1:20 - 1:22
    kind of limited in what it can do so
  • 1:22 - 1:24
    it's it's actually i don't want to say
  • 1:24 - 1:26
    it's not impressive but from a from the
  • 1:26 - 1:27
    standpoint of computer technology is
  • 1:27 - 1:29
    very impressive but from a standpoint of
  • 1:29 - 1:30
    human interaction it's not very
  • 1:30 - 1:32
    impressive at all so what the kernel
  • 1:32 - 1:35
    does is as soon as it fires up the next
  • 1:35 - 1:37
    thing that it does is it launches what's
  • 1:37 - 1:40
    called an init process right and the
  • 1:40 - 1:42
    init process is what actually starts all
  • 1:42 - 1:43
    the various services and makes your
  • 1:43 - 1:46
    operating system work it seems super
  • 1:46 - 1:48
    impressive to us but technologically
  • 1:48 - 1:49
    it's really basic in fact in the
  • 1:49 - 1:50
    original
  • 1:50 - 1:52
    versions of unix they use what was just
  • 1:52 - 1:55
    called the cis v init the sysv system 5
  • 1:55 - 1:57
    was for tracking one of their releases
  • 1:57 - 2:00
    uh and the this is via net what it would
  • 2:00 - 2:02
    do is it just had a folder with a bunch
  • 2:02 - 2:03
    of scripts in it and it would run the
  • 2:03 - 2:05
    scripts one after the other and that
  • 2:05 - 2:07
    would start your system up and then when
  • 2:07 - 2:08
    you got to a log imprompt it was because
  • 2:08 - 2:10
    at some stage a script was run that
  • 2:10 - 2:13
    launched a shell or a console and then
  • 2:13 - 2:14
    made that available to you
  • 2:14 - 2:16
    that's all it was right well
  • 2:16 - 2:18
    that sounds really simple because it was
  • 2:18 - 2:20
    really simple and it had certain
  • 2:20 - 2:22
    drawbacks certain problems certain
  • 2:22 - 2:23
    things that made it not efficient the
  • 2:23 - 2:25
    the number one problem
  • 2:25 - 2:28
    was that cisvi and it ran everything in
  • 2:28 - 2:31
    a serial order one after the other so it
  • 2:31 - 2:33
    would run script one then script two
  • 2:33 - 2:35
    then script three and if script three
  • 2:35 - 2:37
    took a long time or if it hung the
  • 2:37 - 2:39
    system just waited right there right so
  • 2:39 - 2:41
    it wasn't terribly fast so that was one
  • 2:41 - 2:43
    problem that it had the other problem
  • 2:43 - 2:45
    was that the scripts were just run when
  • 2:45 - 2:48
    the system booted up right and
  • 2:48 - 2:50
    after that if something changed on the
  • 2:50 - 2:51
    system the scripts wouldn't detect
  • 2:51 - 2:53
    unless you recalled them that wasn't a
  • 2:53 - 2:55
    problem back in the 1970s and in the
  • 2:55 - 2:58
    1980s but fast forward to
  • 2:58 - 3:00
    2019 where we are
  • 3:00 - 3:02
    we are constantly adding and removing
  • 3:02 - 3:04
    hardware from our systems you might have
  • 3:04 - 3:06
    usb thumb drives or webcams or whatever
  • 3:06 - 3:08
    that plug in and go
  • 3:08 - 3:11
    imagine if you plugged in a usb key
  • 3:11 - 3:12
    and the system didn't even know that
  • 3:12 - 3:14
    happened right and we had to run these
  • 3:14 - 3:15
    scripts and tell it to look for that
  • 3:15 - 3:19
    missing hardware so that is is a problem
  • 3:19 - 3:21
    with cisv init
  • 3:21 - 3:24
    system d was created as the next
  • 3:24 - 3:26
    generation of that to try and replace
  • 3:26 - 3:27
    this via net and do it in a different
  • 3:27 - 3:30
    way so what systemd does is it's not
  • 3:30 - 3:32
    just a series of scripts systemd is an
  • 3:32 - 3:34
    actual program it's an actual uh demon
  • 3:34 - 3:36
    it actually stands for system demon and
  • 3:36 - 3:38
    if you've never heard that term it's d a
  • 3:38 - 3:41
    e m o n daemon and in the the unix and
  • 3:41 - 3:44
    linux world any program that runs in the
  • 3:44 - 3:46
    background is part of the operating
  • 3:46 - 3:48
    system that runs unattended from the
  • 3:48 - 3:50
    user is called a demon it's just you
  • 3:50 - 3:51
    know doing its little job in the
  • 3:51 - 3:53
    background it actually comes from a
  • 3:53 - 3:55
    physics book that described some weird
  • 3:55 - 3:57
    physical motion
  • 3:57 - 3:59
    it's a crazy history some other book
  • 3:59 - 4:02
    yeah but but basically uh you know these
  • 4:02 - 4:04
    demons are what the system is running in
  • 4:04 - 4:05
    the background and it used to be the
  • 4:05 - 4:07
    init scripts that would call them now
  • 4:07 - 4:10
    it's the the systemd executable so this
  • 4:10 - 4:12
    program runs and it doesn't just run
  • 4:12 - 4:14
    when the system boots up it stays
  • 4:14 - 4:15
    running so systemd stays running the
  • 4:15 - 4:18
    whole time your system is online and
  • 4:18 - 4:20
    it's able to do things like well one it
  • 4:20 - 4:21
    can detect hardware changes because it's
  • 4:21 - 4:23
    always running
  • 4:23 - 4:24
    two
  • 4:24 - 4:26
    it can do things in parallel it can say
  • 4:26 - 4:28
    all right i'm gonna run these five
  • 4:28 - 4:30
    routines all at the same time and if one
  • 4:30 - 4:31
    hangs it's no big deal because i'm still
  • 4:31 - 4:33
    doing the other four and so it's faster
  • 4:33 - 4:36
    right system d is faster more stable
  • 4:36 - 4:37
    there are some people out there that
  • 4:37 - 4:39
    don't like system d you'll hear some
  • 4:39 - 4:40
    people complain about it from time to
  • 4:40 - 4:43
    time because it moves away from
  • 4:43 - 4:45
    tradition right traditionally you can
  • 4:45 - 4:48
    control your entire unix-like operating
  • 4:48 - 4:50
    system by modifying some text files with
  • 4:50 - 4:52
    systemd it's not like that it does have
  • 4:52 - 4:54
    configuration files but it's actually
  • 4:54 - 4:55
    doing a lot of stuff in a binary and
  • 4:55 - 4:58
    some people if you're like a unix purist
  • 4:58 - 4:59
    that that's not something you're happy
  • 4:59 - 5:02
    about but i'll tell you as a linux
  • 5:02 - 5:04
    administrator myself i love it i think
  • 5:04 - 5:06
    it's faster it works really well and
  • 5:06 - 5:07
    it's a great way to deal things so
  • 5:07 - 5:09
    systemd
  • 5:09 - 5:11
    is is pretty prominent and it's
  • 5:11 - 5:12
    typically how we're gonna be
  • 5:12 - 5:13
    manipulating services so going back to
  • 5:13 - 5:15
    zack's original question hey how are
  • 5:15 - 5:16
    these services controlled
  • 5:16 - 5:19
    you power on your system right uh your
  • 5:19 - 5:21
    bios kicks in it reaches out to the hard
  • 5:21 - 5:24
    drive it finds the boot files loads up
  • 5:24 - 5:26
    that linux kernel then the linux kernel
  • 5:26 - 5:28
    launches init and in this case it would
  • 5:28 - 5:30
    be a systemd that it fires up and then
  • 5:30 - 5:32
    systemd goes the routine of starting
  • 5:32 - 5:33
    everything else that you need to
  • 5:33 - 5:35
    interact with your system and bring it
  • 5:35 - 5:37
    online if it's supposed to right if
  • 5:37 - 5:38
    there's things that aren't supposed to
  • 5:38 - 5:40
    come on it leaves them off they system d
  • 5:40 - 5:41
    is what's actually controlling that so
  • 5:41 - 5:44
    how do we know if we are actually using
  • 5:44 - 5:46
    system d all right so uh you know a good
  • 5:46 - 5:49
    question i will say that all of the
  • 5:49 - 5:51
    major linux distros these days use
  • 5:51 - 5:54
    systemd so if you get ubuntu you get red
  • 5:54 - 5:57
    hat enterprise linux centos fedora mint
  • 5:57 - 5:58
    um
  • 5:58 - 6:01
    it just goes on and on all of the major
  • 6:01 - 6:03
    distros use systemd by default so the
  • 6:03 - 6:06
    odds are you are using system
  • 6:06 - 6:08
    but it's not 100 there are some distros
  • 6:08 - 6:10
    out there that have chosen not to go
  • 6:10 - 6:12
    with systemd that are following the old
  • 6:12 - 6:14
    model the sysv init or there was
  • 6:14 - 6:16
    actually another uh init system called
  • 6:16 - 6:18
    upstart upstart was really just a slight
  • 6:18 - 6:21
    modification assist via knit it wasn't a
  • 6:21 - 6:24
    full-on like change
  • 6:24 - 6:26
    so you may find some systems to do that
  • 6:26 - 6:27
    typically if you're running older
  • 6:27 - 6:30
    versions like if you're running centos 7
  • 6:30 - 6:31
    you're using system d but if you're
  • 6:31 - 6:35
    running centos 6 you're using upstart uh
  • 6:35 - 6:37
    and if you're running centos five you're
  • 6:37 - 6:38
    running sysv in it right so you know
  • 6:38 - 6:40
    it's kind of changed over time uh if
  • 6:40 - 6:41
    you're running ubuntu they've been
  • 6:41 - 6:43
    running systemd for the last three or
  • 6:43 - 6:44
    four versions i think and then before
  • 6:44 - 6:47
    that they were on sysv init
  • 6:47 - 6:49
    but there are current distros like
  • 6:49 - 6:50
    slackware slackware was actually the
  • 6:50 - 6:53
    very first linux to show that i ran back
  • 6:53 - 6:57
    in 1993 1992 three i think 1993. either
  • 6:57 - 7:00
    way uh it ran cis via knit back then and
  • 7:00 - 7:02
    it runs cisv in it today uh they have
  • 7:02 - 7:04
    not moved over to systemd because they
  • 7:04 - 7:06
    follow that model of a pure unix type
  • 7:06 - 7:08
    deployment um there's other ones there's
  • 7:08 - 7:10
    variants of debian i think there's one
  • 7:10 - 7:13
    it's called devon that actually uses uh
  • 7:13 - 7:16
    cisv init instead of systemd but none of
  • 7:16 - 7:18
    the major distro so if you're deploying
  • 7:18 - 7:20
    something in a business if you you're
  • 7:20 - 7:21
    deploying something where you need
  • 7:21 - 7:23
    support all of those companies are using
  • 7:23 - 7:26
    systemd but we can verify right let's be
  • 7:26 - 7:28
    sure right so i've got a centos box here
  • 7:28 - 7:30
    in front of me and i'm running centos 7
  • 7:30 - 7:34
    and i know that it defaults to systemd i
  • 7:34 - 7:35
    shouldn't say default like it just runs
  • 7:35 - 7:38
    systemd but if we want to verify that
  • 7:38 - 7:39
    there's a few different ways
  • 7:39 - 7:41
    i mentioned the boot order earlier and
  • 7:41 - 7:44
    when i turn the computer on the kernel
  • 7:44 - 7:46
    fires up and the first thing it does is
  • 7:46 - 7:49
    it starts init right so technically your
  • 7:49 - 7:52
    init process is the very first process
  • 7:52 - 7:54
    that runs it's number one so if we use a
  • 7:54 - 7:56
    utility like ps right this is the the
  • 7:56 - 7:58
    process show command it shows me all the
  • 7:58 - 8:00
    processes running in the background if i
  • 8:00 - 8:01
    do a ps
  • 8:01 - 8:04
    aux right that says show all of the
  • 8:04 - 8:06
    processes with the user that's attached
  • 8:06 - 8:07
    to them
  • 8:07 - 8:10
    and uh x i can't remember what x does
  • 8:10 - 8:12
    it's like a
  • 8:12 - 8:13
    services or something i can't remember
  • 8:13 - 8:16
    what x is but if i do ps aux and i run
  • 8:16 - 8:17
    that it will show me all the processes
  • 8:17 - 8:19
    that are running and if you look at
  • 8:19 - 8:21
    these process numbers right it's this
  • 8:21 - 8:24
    second column i've got process
  • 8:24 - 8:28
    13999 process 14 416. when a process run
  • 8:28 - 8:30
    it gets a number and when it closes the
  • 8:30 - 8:32
    number goes away and it just kind of
  • 8:32 - 8:34
    keeps incrementing and growing so over
  • 8:34 - 8:37
    14 000 processes have run since i booted
  • 8:37 - 8:38
    this machine up yeah it's a couple which
  • 8:38 - 8:40
    hasn't been up that long right i've been
  • 8:40 - 8:42
    up for an hour and a half
  • 8:42 - 8:45
    and so so that's a big number but if i
  • 8:45 - 8:47
    scroll up on that list let's just scroll
  • 8:47 - 8:49
    scroll scroll the numbers get smaller
  • 8:49 - 8:51
    and smaller these are processes that ran
  • 8:51 - 8:53
    early on and are still running and i can
  • 8:53 - 8:57
    find process number one right there pid
  • 8:57 - 8:59
    number one and if i look to the side
  • 8:59 - 9:03
    over here it's slash usr slash lib
  • 9:03 - 9:04
    system d
  • 9:04 - 9:07
    system d that tells me that i'm running
  • 9:07 - 9:09
    system d i'm on centos let me jump over
  • 9:09 - 9:11
    to ubuntu uh so this is an ubuntu
  • 9:11 - 9:12
    machine
  • 9:12 - 9:15
    and i can do the exact same thing here
  • 9:15 - 9:17
    if i jump into my terminal
  • 9:17 - 9:20
    and i'll just do ps aux and i'm just
  • 9:20 - 9:21
    going to feed it in the head command
  • 9:21 - 9:23
    save a little time and there's my
  • 9:23 - 9:26
    process id1 and i can see oh
  • 9:26 - 9:28
    this one's actually a little interesting
  • 9:28 - 9:31
    it's telling me slash sbin slash init
  • 9:31 - 9:33
    all right now wait a minute i said this
  • 9:33 - 9:35
    defaulted to systemd
  • 9:35 - 9:37
    that's not systemd if you see slash s
  • 9:37 - 9:40
    bin slash init that's cis v init okay
  • 9:40 - 9:43
    however if i relied on this i might get
  • 9:43 - 9:44
    tricked and let me show you what i mean
  • 9:44 - 9:47
    because i'm i'm like 99.9 positive this
  • 9:47 - 9:48
    should be systemd i didn't check before
  • 9:48 - 9:51
    the show so that's my fault but
  • 9:51 - 9:53
    if you pull up a a listing i'm going to
  • 9:53 - 9:56
    do an ls-l of slash s-bin i want to see
  • 9:56 - 9:58
    the binaries they're in that file or in
  • 9:58 - 10:00
    that folder okay and i go in here and
  • 10:00 - 10:02
    find init actually let me just do spin
  • 10:02 - 10:05
    slash init there we go
  • 10:05 - 10:07
    they're tricking us right it's a sim
  • 10:07 - 10:10
    link they have sim linked slash s bin
  • 10:10 - 10:12
    slash init does exist
  • 10:12 - 10:14
    and it's being pointed to slash lib
  • 10:14 - 10:16
    slash system d system d so there we go
  • 10:16 - 10:18
    so it it looked like in the process
  • 10:18 - 10:20
    output that we want now that means that
  • 10:20 - 10:22
    we can't really trust the process output
  • 10:22 - 10:26
    can't we the psa ux it works if we're
  • 10:26 - 10:27
    full on running systemd but it could
  • 10:27 - 10:29
    trick us with older stuff but if we
  • 10:29 - 10:32
    actually look at slash s bin slash init
  • 10:32 - 10:34
    it's in the official standard
  • 10:34 - 10:37
    that any operating system that's using
  • 10:37 - 10:40
    the linux kernel has to have a file in
  • 10:40 - 10:42
    slash s bin slash init even if it's not
  • 10:42 - 10:44
    what's called it has to be there and so
  • 10:44 - 10:46
    that's a more reliable way to look and
  • 10:46 - 10:48
    see what we're running if i jump back
  • 10:48 - 10:50
    over to
  • 10:50 - 10:53
    my centos box and do the same thing
  • 10:53 - 10:55
    in slash s bin i'm going to look for so
  • 10:55 - 10:58
    i'm running ls dash l to get a long
  • 10:58 - 11:00
    output slash s bin init
  • 11:00 - 11:02
    and i can see they've linked it there as
  • 11:02 - 11:04
    well the difference is in the process
  • 11:04 - 11:07
    command that ps aux on centos it's
  • 11:07 - 11:10
    actually showing me the true binary on
  • 11:10 - 11:12
    ubuntu they're showing me the link
  • 11:12 - 11:13
    instead of the binary so they've changed
  • 11:13 - 11:15
    the way that command works but i can see
  • 11:15 - 11:17
    here they're both clearly running s pen
  • 11:17 - 11:19
    now i mean uh systemd now if i looked in
  • 11:19 - 11:21
    here and it actually said slash spin
  • 11:21 - 11:23
    slash init and it was green and that was
  • 11:23 - 11:26
    that then i'm running cis vie init or
  • 11:26 - 11:27
    upstart upstart i mentioned was like an
  • 11:27 - 11:29
    upgrade to csv init not a replace not a
  • 11:29 - 11:32
    uh like a true change so it would be
  • 11:32 - 11:34
    slash s bin slash init as well so i
  • 11:34 - 11:35
    wouldn't be able to tell the difference
  • 11:35 - 11:37
    between upstart and cisv in it but that
  • 11:37 - 11:39
    doesn't matter for us i know we're
  • 11:39 - 11:41
    running systemd
  • 11:41 - 11:43
    so system b starts right after the
  • 11:43 - 11:45
    kernel right yeah and then what happens
  • 11:45 - 11:47
    so it's a big deal right it's the first
  • 11:47 - 11:49
    thing and if system d crashes your
  • 11:49 - 11:51
    system crashed right it's powering
  • 11:51 - 11:52
    everything
  • 11:52 - 11:55
    so once it fires up then it's got to get
  • 11:55 - 11:56
    to work and it says okay now it's time
  • 11:56 - 11:58
    for me to do my job i need to start some
  • 11:58 - 12:00
    services i need to
  • 12:00 - 12:02
    open up some ports on the system for
  • 12:02 - 12:04
    network communication and i need to
  • 12:04 - 12:05
    figure out whether we're going to load a
  • 12:05 - 12:07
    gui or go straight to the command line
  • 12:07 - 12:09
    it has to do all these different things
  • 12:09 - 12:11
    and it does that through the use of unit
  • 12:11 - 12:14
    files all right unit files are stored in
  • 12:14 - 12:16
    if i change directory i'm going to go
  • 12:16 - 12:18
    into slash lib
  • 12:18 - 12:20
    system d
  • 12:20 - 12:22
    slash system all right if you go into
  • 12:22 - 12:24
    that folder right there and pull up a
  • 12:24 - 12:27
    listing what you're going to find is a
  • 12:27 - 12:30
    ton of files and each file will be a
  • 12:30 - 12:34
    name and then it'll end in dot
  • 12:34 - 12:36
    service or dot
  • 12:36 - 12:38
    timer.target.slice each one is kind of
  • 12:38 - 12:40
    something different most of them are dot
  • 12:40 - 12:42
    service right those dot service files
  • 12:42 - 12:44
    are identifying demons demons are gonna
  • 12:44 - 12:45
    run in the background those are services
  • 12:45 - 12:48
    or applications that run and just keep
  • 12:48 - 12:51
    running and do the thing all right
  • 12:51 - 12:54
    other ones though like dot target that's
  • 12:54 - 12:56
    a user environment right so there's a
  • 12:56 - 12:58
    dot target file for if i want to have a
  • 12:58 - 13:01
    gui right it's actually i think called
  • 13:01 - 13:03
    graphical or something or another uh
  • 13:03 - 13:04
    it's in here
  • 13:04 - 13:05
    remembering the names of these is pretty
  • 13:05 - 13:06
    hard because there's so many yeah
  • 13:06 - 13:08
    graphical dot target right there uh and
  • 13:08 - 13:10
    then there's a command line one which is
  • 13:10 - 13:12
    actually called multi-user.target
  • 13:12 - 13:14
    um there's several others that are like
  • 13:14 - 13:16
    that you'll also find dot socket which
  • 13:16 - 13:19
    is identifying a network port that's
  • 13:19 - 13:21
    going to be opened or possibly a name
  • 13:21 - 13:22
    pipe or something that'll allow an
  • 13:22 - 13:24
    application to talk to another
  • 13:24 - 13:26
    application via network service
  • 13:26 - 13:29
    let's see that was targets services and
  • 13:29 - 13:31
    sockets those are the most common uh you
  • 13:31 - 13:33
    also see dot mount so those are where
  • 13:33 - 13:35
    it'll mount a hard drive partition you
  • 13:35 - 13:37
    still have the file system table the
  • 13:37 - 13:40
    slash etc f-stab file but you don't need
  • 13:40 - 13:41
    it anymore if you don't want because
  • 13:41 - 13:44
    systemd can use dot mount unit files to
  • 13:44 - 13:46
    be able to specify what to reach out to
  • 13:46 - 13:49
    so when systemd starts it's actually
  • 13:49 - 13:50
    parsing all of the stuff in this
  • 13:50 - 13:52
    directory and looking at it and saying
  • 13:52 - 13:55
    all right what do i need to do and if we
  • 13:55 - 13:58
    pick pick somebody here somebody easy
  • 13:58 - 14:01
    ssh all right so ssh
  • 14:01 - 14:03
    that's the secure shell daemon and it's
  • 14:03 - 14:06
    running by default on most linux systems
  • 14:06 - 14:08
    so that we can create a secure remote
  • 14:08 - 14:09
    shell connect in and get a command
  • 14:09 - 14:12
    prompt right so it should be starting
  • 14:12 - 14:14
    when the system starts if i look inside
  • 14:14 - 14:18
    of that file so let me just get
  • 14:18 - 14:20
    sshd.service
  • 14:20 - 14:21
    there we go there's not a whole heck of
  • 14:21 - 14:23
    a lot in here right so it starts with
  • 14:23 - 14:24
    this
  • 14:24 - 14:26
    blocked quote right here where it says
  • 14:26 - 14:27
    unit
  • 14:27 - 14:30
    and from there it goes on to specify
  • 14:30 - 14:32
    information about that daemon so i can
  • 14:32 - 14:34
    see that this is the open ssh server
  • 14:34 - 14:35
    daemon
  • 14:35 - 14:37
    and it has documentation right there's a
  • 14:37 - 14:39
    man file that's available for it so it's
  • 14:39 - 14:41
    got that registered here and then it's
  • 14:41 - 14:44
    saying we want to start it but don't
  • 14:44 - 14:46
    start it right away you need to make
  • 14:46 - 14:48
    sure that the network.target environment
  • 14:48 - 14:49
    has started right we have networking
  • 14:49 - 14:53
    working before we can start ssh and we
  • 14:53 - 14:56
    need the sshd keygen service running so
  • 14:56 - 14:58
    this is setting up a hierarchy right
  • 14:58 - 15:00
    like an order and dependencies that
  • 15:00 - 15:02
    systemd is able to use so it says okay i
  • 15:02 - 15:04
    can't start this one first i need to
  • 15:04 - 15:07
    start network.target and i need to start
  • 15:07 - 15:09
    sshd-keygen.servers
  • 15:09 - 15:10
    so once those are started then i can
  • 15:10 - 15:11
    come back and start this one and
  • 15:11 - 15:13
    remember it's doing all this in parallel
  • 15:13 - 15:14
    so it can reach out and try and do
  • 15:14 - 15:16
    multiple things at once
  • 15:16 - 15:18
    and then after that it says once right
  • 15:18 - 15:20
    after says i can't start until these are
  • 15:20 - 15:24
    started but once means once i start i
  • 15:24 - 15:26
    want this other thing to start as well
  • 15:26 - 15:28
    now
  • 15:28 - 15:31
    sshd-keygen service is listed twice
  • 15:31 - 15:33
    and what that's saying is it needs to be
  • 15:33 - 15:35
    started when i start
  • 15:35 - 15:37
    but if something goes wrong i need that
  • 15:37 - 15:39
    one started again because i depend on it
  • 15:39 - 15:40
    right that's establishing that
  • 15:40 - 15:42
    dependency too so we've got those
  • 15:42 - 15:44
    entries and then after that we see the
  • 15:44 - 15:46
    actual service right and so it's telling
  • 15:46 - 15:49
    me i can find my configuration in etc
  • 15:49 - 15:51
    sysconfig sshd that's where the
  • 15:51 - 15:53
    configuration is going to be and then
  • 15:53 - 15:55
    when we execute when we start here's the
  • 15:55 - 15:57
    command that it runs slash user slash
  • 15:57 - 16:01
    spin sshd that's an executable dash d
  • 16:01 - 16:02
    tells it to run as a daemon run in the
  • 16:02 - 16:04
    background otherwise when that shell
  • 16:04 - 16:06
    closed the the application would close
  • 16:06 - 16:07
    we can see what to do when we close it
  • 16:07 - 16:09
    and it's going to run the kill command
  • 16:09 - 16:10
    and it's going to shut that one down
  • 16:10 - 16:12
    you can see how to kill it uh your just
  • 16:12 - 16:14
    uses a process execute sounds really
  • 16:14 - 16:16
    violent but just exiting
  • 16:16 - 16:18
    and then restart if there's a failure if
  • 16:18 - 16:20
    it crashes it's going to try and restart
  • 16:20 - 16:22
    it and if it does a restart it'll wait
  • 16:22 - 16:24
    42 seconds right this is all defined
  • 16:24 - 16:26
    right here when we install this service
  • 16:26 - 16:28
    if i want it running every time it's
  • 16:28 - 16:30
    going to install it and attach it to
  • 16:30 - 16:33
    multi-user.target so when that starts
  • 16:33 - 16:35
    which is our our command line when the
  • 16:35 - 16:37
    command line starts it's going to make
  • 16:37 - 16:39
    sure that ssh starts as well these are
  • 16:39 - 16:41
    unit files and the unit files are just
  • 16:41 - 16:43
    text you can you can actually go in and
  • 16:43 - 16:45
    edit them if you want it's not a great
  • 16:45 - 16:47
    idea to edit these most of the time when
  • 16:47 - 16:49
    you install when you install the sshd
  • 16:49 - 16:52
    service it creates these files for you
  • 16:52 - 16:53
    right so i didn't create these they were
  • 16:53 - 16:56
    made for me if i want to modify them i
  • 16:56 - 16:58
    usually will not modify it here because
  • 16:58 - 17:01
    if we get an update right so sshd gets
  • 17:01 - 17:03
    an update and they update this unit file
  • 17:03 - 17:04
    it's going to overwrite my changes i'm
  • 17:04 - 17:06
    going to lose them so if you're going to
  • 17:06 - 17:08
    make changes don't make them in this
  • 17:08 - 17:09
    folder so i'm let me get back in here
  • 17:09 - 17:11
    actually let me zoom back out there we
  • 17:11 - 17:12
    go
  • 17:12 - 17:15
    so i'm in slash lib systemd system you
  • 17:15 - 17:17
    really should never edit anything in
  • 17:17 - 17:19
    slash lib it should just be left alone
  • 17:19 - 17:22
    but if you go into slash etc
  • 17:22 - 17:25
    slash system d slash system all right
  • 17:25 - 17:26
    and that folder might not exist you
  • 17:26 - 17:28
    might have to make it on centos it's
  • 17:28 - 17:31
    there by default so slash etc systemd
  • 17:31 - 17:34
    system as opposed to slash lib system d
  • 17:34 - 17:35
    slash system
  • 17:35 - 17:37
    when you look in here
  • 17:37 - 17:39
    you'll find service files and target
  • 17:39 - 17:43
    files and once and so on these are where
  • 17:43 - 17:46
    we're overriding what's done inside of
  • 17:46 - 17:48
    systemd's folder so if i want to make a
  • 17:48 - 17:50
    change i shouldn't go and change the
  • 17:50 - 17:52
    files in slash lib i can come right in
  • 17:52 - 17:53
    here and create a file with the same
  • 17:53 - 17:55
    name and when i do that this file will
  • 17:55 - 17:56
    override the other one and when an
  • 17:56 - 17:59
    update comes along it'll leave my file
  • 17:59 - 18:00
    alone right now i haven't overridden
  • 18:00 - 18:02
    anything and so everything in here was
  • 18:02 - 18:04
    done by the system looks like dbus is
  • 18:04 - 18:07
    doing some stuff we even have cis in it
  • 18:07 - 18:08
    which is for backwards compatibility
  • 18:08 - 18:10
    with cisv init so some of these entries
  • 18:10 - 18:12
    are already in here most of these are
  • 18:12 - 18:13
    just links
  • 18:13 - 18:15
    in fact i think all of them are dis
  • 18:15 - 18:17
    links um
  • 18:17 - 18:18
    well no some of them just have weird
  • 18:18 - 18:20
    permissions on them but many of them are
  • 18:20 - 18:22
    links to other locations and you'll see
  • 18:22 - 18:24
    them pointing to slash lib or somewhere
  • 18:24 - 18:26
    to override an activity
  • 18:26 - 18:28
    from somewhere else so that's how that
  • 18:28 - 18:30
    kind of functions and that's really the
  • 18:30 - 18:32
    heart and soul of systemd systemd is a
  • 18:32 - 18:34
    binary it's an executable that runs uh
  • 18:34 - 18:36
    in fact i think i browse right past it
  • 18:36 - 18:40
    if i go into slash lib system
  • 18:40 - 18:41
    d
  • 18:41 - 18:43
    and we look in here
  • 18:43 - 18:45
    somewhere right here there we go there's
  • 18:45 - 18:47
    the systemd executable it's actually not
  • 18:47 - 18:49
    very flashy at all
  • 18:49 - 18:50
    um
  • 18:50 - 18:51
    it's
  • 18:51 - 18:54
    let me do a human readable size on this
  • 18:54 - 18:54
    one
  • 18:54 - 18:57
    it's a blazing 1.6 megabytes
  • 18:57 - 19:00
    and yet that 1.6 megabytes is powering
  • 19:00 - 19:03
    my entire user environment right now the
  • 19:03 - 19:04
    kernel is handling my hardware
  • 19:04 - 19:07
    interaction and then systemd is making
  • 19:07 - 19:09
    all of my software work i mean this is
  • 19:09 - 19:11
    super important software and it's really
  • 19:11 - 19:13
    really small and then it relies on all
  • 19:13 - 19:15
    those configuration files to do its job
  • 19:15 - 19:17
    well do we have to create unit files for
  • 19:17 - 19:19
    new services done
  • 19:19 - 19:21
    you can so if i'm installing a new
  • 19:21 - 19:22
    service you can go in and create and
  • 19:22 - 19:24
    define them yourself i've had to do that
  • 19:24 - 19:26
    on occasion but normally the services
  • 19:26 - 19:28
    will create them automatically right so
  • 19:28 - 19:30
    let's say um let me give you an example
  • 19:30 - 19:32
    i wanna i wanna be a web server right so
  • 19:32 - 19:35
    i wanna install apache well if i take a
  • 19:35 - 19:37
    look inside of
  • 19:37 - 19:40
    my systemd library folder so i'm back in
  • 19:40 - 19:42
    slash lib systemd system
  • 19:42 - 19:44
    if i look for any file that starts with
  • 19:44 - 19:47
    http oh shoot i actually see it right
  • 19:47 - 19:48
    there httpd.service so it looks like i'm
  • 19:48 - 19:50
    already a web server
  • 19:50 - 19:53
    that file is defining the apache service
  • 19:53 - 19:54
    and getting it set up to do its job
  • 19:54 - 19:56
    right well i didn't create that file at
  • 19:56 - 19:58
    least i don't remember doing it so when
  • 19:58 - 20:00
    i installed httpd
  • 20:00 - 20:02
    it must have created that right if i
  • 20:02 - 20:05
    were to remove httpd so if i do
  • 20:05 - 20:09
    a sudo yum
  • 20:09 - 20:10
    remove or
  • 20:10 - 20:11
    we'll just remove
  • 20:11 - 20:13
    httpd
  • 20:13 - 20:15
    there we go so i'm going to uninstall it
  • 20:15 - 20:17
    so i'm uninstalling httpd
  • 20:17 - 20:21
    and now i'll just take a a look again
  • 20:21 - 20:24
    and i see there's no unit file defined
  • 20:24 - 20:25
    for it anymore so when it uninstalled
  • 20:25 - 20:27
    httpd it knew to take away that unit
  • 20:27 - 20:31
    file and if i install it back again
  • 20:31 - 20:32
    so i'm just going to come in here and do
  • 20:32 - 20:33
    an install
  • 20:33 - 20:35
    and when i do that it's going to go
  • 20:35 - 20:38
    through it's going to do the install
  • 20:38 - 20:42
    there it goes and if i take a look
  • 20:43 - 20:44
    i can see it created that file again
  • 20:44 - 20:46
    right so most services if you're
  • 20:46 - 20:48
    installing them from a package file
  • 20:48 - 20:50
    whoever the developer is that created
  • 20:50 - 20:51
    that software will know hey this is the
  • 20:51 - 20:52
    unit file i need and i'll go ahead and
  • 20:52 - 20:54
    create it for you so you really don't
  • 20:54 - 20:55
    have to worry about it you don't have to
  • 20:55 - 20:57
    go in and edit these things it just does
  • 20:57 - 20:59
    it now i will tell you sometimes you
  • 20:59 - 21:01
    install software and it doesn't create
  • 21:01 - 21:03
    the unit file for you right
  • 21:03 - 21:05
    and that might be software that's
  • 21:05 - 21:08
    designed to be run on demand okay
  • 21:08 - 21:10
    you need unit files for software that
  • 21:10 - 21:11
    runs in the background that runs
  • 21:11 - 21:13
    automatic without interaction i want
  • 21:13 - 21:14
    this web server running all the time it
  • 21:14 - 21:16
    needs unifile but if i have something
  • 21:16 - 21:19
    like openoffice right openoffice i need
  • 21:19 - 21:21
    it to run when i'm interacting with it i
  • 21:21 - 21:22
    don't want it running in the background
  • 21:22 - 21:24
    so there's not going to be a unit file
  • 21:24 - 21:26
    for openoffice those are just user
  • 21:26 - 21:28
    applications all right but sometimes
  • 21:28 - 21:30
    when you install a service it still
  • 21:30 - 21:31
    doesn't create the unit file because
  • 21:31 - 21:33
    most services don't start automatically
  • 21:33 - 21:35
    you've got to configure them and we do
  • 21:35 - 21:37
    that with systemctl
  • 21:37 - 21:40
    systemctl is a utility that is packaged
  • 21:40 - 21:42
    alongside systemd it's the system
  • 21:42 - 21:45
    control utility and it lets us control
  • 21:45 - 21:47
    system d and do things that otherwise
  • 21:47 - 21:49
    might require us to edit some files so
  • 21:49 - 21:54
    for example if i want httpd to start
  • 21:54 - 21:55
    right now
  • 21:55 - 21:57
    i could do sudo
  • 21:57 - 21:59
    systemctl
  • 21:59 - 22:00
    start
  • 22:00 - 22:03
    httpd right and it's going to read the
  • 22:03 - 22:04
    unit file it's actually looking for that
  • 22:04 - 22:06
    unit file and
  • 22:06 - 22:07
    i should have typed this the whole way
  • 22:07 - 22:10
    and said httpd.service
  • 22:10 - 22:12
    because that's the unit file name and
  • 22:12 - 22:14
    it's going to look for it find it and
  • 22:14 - 22:16
    start it okay if you leave the extension
  • 22:16 - 22:19
    off it looks for services first because
  • 22:19 - 22:21
    i'm i'm telling it to start something
  • 22:21 - 22:23
    and that way it doesn't look for
  • 22:23 - 22:26
    socket.target and those guys right but
  • 22:26 - 22:27
    if you want the full name would actually
  • 22:27 - 22:29
    have service on the end so it's going to
  • 22:29 - 22:31
    find it it's going to start it all right
  • 22:31 - 22:33
    now we can start a service even if it
  • 22:33 - 22:35
    doesn't have a unit file if it's got
  • 22:35 - 22:36
    dependencies things will break but even
  • 22:36 - 22:38
    if it didn't have one you could do that
  • 22:38 - 22:41
    but when the system reboots
  • 22:41 - 22:42
    that service is not going to be started
  • 22:42 - 22:44
    by default unless we tell it and we
  • 22:44 - 22:48
    could go in and modify the the actual
  • 22:48 - 22:50
    service file and or the the unit file
  • 22:50 - 22:53
    and actually tell it yes
  • 22:53 - 22:55
    multi multi-user or graphical depends on
  • 22:55 - 22:58
    this file we need hdbd to start right or
  • 22:58 - 22:59
    you can just do it right here with
  • 22:59 - 23:02
    systemctl you can say systemctl
  • 23:02 - 23:04
    enable
  • 23:04 - 23:07
    httpd right and when i run that look
  • 23:07 - 23:08
    what it did
  • 23:08 - 23:12
    created a sim link from slash etc
  • 23:12 - 23:14
    systemd system
  • 23:14 - 23:15
    multi-user.target.once slash
  • 23:15 - 23:18
    httpd.service so it put a sim link in
  • 23:18 - 23:20
    slash etc
  • 23:20 - 23:23
    right and it's pointing to slash user
  • 23:23 - 23:25
    slash lib system d
  • 23:25 - 23:28
    system slash http dot service it didn't
  • 23:28 - 23:30
    edit anything inside of slash lib or
  • 23:30 - 23:33
    slash user slash lib it edited instead
  • 23:33 - 23:35
    inside of etc and even then it wasn't
  • 23:35 - 23:36
    really an edit it was just a link that
  • 23:36 - 23:39
    says now whenever i start the multi-user
  • 23:39 - 23:43
    target i will also start httpd
  • 23:43 - 23:44
    it did that for me i didn't have to
  • 23:44 - 23:46
    create unit files i didn't have to go
  • 23:46 - 23:48
    and modify etc it was just done
  • 23:48 - 23:50
    automatically and if i say you know what
  • 23:50 - 23:52
    i want the web server but i don't want
  • 23:52 - 23:54
    it to start automatically i can just
  • 23:54 - 23:56
    come in and say disable
  • 23:56 - 23:59
    and when you do that it removes the link
  • 23:59 - 24:01
    it didn't disable apache i can still run
  • 24:01 - 24:03
    apache if i do
  • 24:03 - 24:06
    sudo systemctl start
  • 24:06 - 24:07
    httpd
  • 24:07 - 24:08
    like that
  • 24:08 - 24:10
    and then i can do status so
  • 24:10 - 24:14
    sudo systemctl status httpd and it will
  • 24:14 - 24:16
    actually show me that it's active and
  • 24:16 - 24:18
    running right now it's up and
  • 24:18 - 24:20
    operational okay
  • 24:20 - 24:22
    but looking up here it says that it's
  • 24:22 - 24:25
    loaded but it also tells me that it's
  • 24:25 - 24:27
    disabled which means if i reboot apache
  • 24:27 - 24:29
    is not going to be running anymore right
  • 24:29 - 24:32
    if i go back and enable it again
  • 24:32 - 24:33
    let me do that
  • 24:33 - 24:35
    and then we pull that status what i'm
  • 24:35 - 24:38
    going to see now is that the service is
  • 24:38 - 24:40
    enabled so if i reboot apache is going
  • 24:40 - 24:42
    to come back up and we'll be in business
  • 24:42 - 24:44
    so the important part here is that we do
  • 24:44 - 24:45
    all of this
  • 24:45 - 24:47
    without ever actually editing the file
  • 24:47 - 24:50
    system ctl does it all behind the scenes
  • 24:50 - 24:52
    for us so this is another area we kind
  • 24:52 - 24:54
    of deviate away from the way that unix
  • 24:54 - 24:55
    used to be where we'd edit all these
  • 24:55 - 24:57
    script files now it's all automated
  • 24:57 - 24:59
    through systemct how does systemd keep
  • 24:59 - 25:01
    track of which services to run
  • 25:01 - 25:03
    so we've kind of seen that a little bit
  • 25:03 - 25:05
    with our dependencies but it really
  • 25:05 - 25:07
    boils down to the target files right the
  • 25:07 - 25:08
    target files are what defines what's
  • 25:08 - 25:10
    going to get fired up and and so on uh
  • 25:10 - 25:11
    so let's take a look at one of those
  • 25:11 - 25:14
    target files uh if i give what folder am
  • 25:14 - 25:16
    i in i'm in the right folder slash lib
  • 25:16 - 25:18
    system t system
  • 25:18 - 25:21
    if i pull up a listing of star.target
  • 25:21 - 25:23
    all right you'll see a lot of targets
  • 25:23 - 25:26
    right targets are like collections of
  • 25:26 - 25:28
    unit files it says hey if i want the
  • 25:28 - 25:30
    network to function i've got a network
  • 25:30 - 25:32
    target and here's all the stuff i need
  • 25:32 - 25:33
    for the network to function and you'll
  • 25:33 - 25:35
    see other things in here that are like
  • 25:35 - 25:38
    that you know if i want uh remote crypt
  • 25:38 - 25:40
    encryption to work or reboot to work or
  • 25:40 - 25:42
    swap files to work they've all got
  • 25:42 - 25:44
    different targets and those targets are
  • 25:44 - 25:46
    defining all the services needed to make
  • 25:46 - 25:48
    that work so if i want to boot to a
  • 25:48 - 25:49
    command line
  • 25:49 - 25:52
    just to a command line then
  • 25:52 - 25:55
    i need what's in multi-user.target
  • 25:55 - 25:57
    if i take a look at that file let's use
  • 25:57 - 25:58
    less on
  • 25:58 - 26:01
    multi-user dot target
  • 26:01 - 26:03
    i can look in there and
  • 26:03 - 26:06
    it's actually not a very big file at all
  • 26:06 - 26:08
    right but that's because it's including
  • 26:08 - 26:10
    some things that it needs it says all
  • 26:10 - 26:11
    right multi-user can start whenever it
  • 26:11 - 26:14
    wants right so i don't see a actually do
  • 26:14 - 26:15
    i have a required don't i here's a
  • 26:15 - 26:17
    require that says basic.target so before
  • 26:17 - 26:19
    multi-user can start anything in
  • 26:19 - 26:22
    basic.target has to start then this one
  • 26:22 - 26:25
    can start and once it starts afterwards
  • 26:25 - 26:26
    we'll fire up basic.target if it isn't
  • 26:26 - 26:28
    already but we've got rescue.service
  • 26:28 - 26:29
    rescue.target we've got a few other
  • 26:29 - 26:32
    things uh that can be triggered as well
  • 26:32 - 26:33
    to you know get our system up and and
  • 26:33 - 26:36
    running well let's look at basic.target
  • 26:36 - 26:39
    so if i just i'll cat basic.target and i
  • 26:39 - 26:41
    look in here it's also not very big at
  • 26:41 - 26:44
    all right but it's got that it requires
  • 26:44 - 26:46
    systenit.target
  • 26:46 - 26:47
    and it's calling several other things
  • 26:47 - 26:50
    too and if i look at
  • 26:50 - 26:51
    sysinit.target we're kind of following
  • 26:51 - 26:53
    this back right going back back back and
  • 26:53 - 26:55
    we see how it's calling more and more
  • 26:55 - 26:56
    things
  • 26:56 - 26:59
    all of this is coming together to build
  • 26:59 - 27:01
    the environment that that is required
  • 27:01 - 27:03
    for our system and boot if i want a
  • 27:03 - 27:05
    graphical user interface then i would
  • 27:05 - 27:08
    need graphical.target
  • 27:08 - 27:10
    and you'll see where it depends on
  • 27:10 - 27:12
    multi-user the command line has to work
  • 27:12 - 27:14
    before i can launch stuff to get the gui
  • 27:14 - 27:15
    right they all are in their
  • 27:15 - 27:18
    interdependent as a human it would take
  • 27:18 - 27:19
    me forever to sift through all these
  • 27:19 - 27:21
    files and build out the tree of
  • 27:21 - 27:23
    dependencies but systemd does it every
  • 27:23 - 27:25
    time you boot it parses through these
  • 27:25 - 27:28
    files figures out the dependencies it uh
  • 27:28 - 27:29
    it actually doesn't monitor the files on
  • 27:29 - 27:31
    an ongoing basis if i change a file
  • 27:31 - 27:34
    right now it won't recognize it unless i
  • 27:34 - 27:36
    tell it to reload right so you can go in
  • 27:36 - 27:37
    and well you can reboot your system it's
  • 27:37 - 27:39
    one way to do it or like with a service
  • 27:39 - 27:41
    you use the restart command and it'll
  • 27:41 - 27:42
    reload the unit file for that service
  • 27:42 - 27:44
    but otherwise it's figuring out all
  • 27:44 - 27:46
    those dependencies kind of mapping it
  • 27:46 - 27:47
    together it gets pretty complex because
  • 27:47 - 27:49
    the sheer amount of files but at the end
  • 27:49 - 27:51
    of the day they are just simple text
  • 27:51 - 27:52
    files you can view it all well can we
  • 27:52 - 27:54
    change between the targets oh you can
  • 27:54 - 27:56
    yeah you know my system right now if i
  • 27:56 - 27:57
    were to reboot
  • 27:57 - 28:00
    it's set to default to the graphical
  • 28:00 - 28:02
    user interface so it it's basically set
  • 28:02 - 28:04
    to boot to graphical.target right but if
  • 28:04 - 28:07
    this is a server i don't need a gui
  • 28:07 - 28:09
    i might want to have the gui installed
  • 28:09 - 28:10
    so when i'm sitting at the server i can
  • 28:10 - 28:12
    use it but the rest of the time i don't
  • 28:12 - 28:14
    need a gui run so i could actually
  • 28:14 - 28:16
    switch targets and tell it hey don't
  • 28:16 - 28:18
    don't run graphical anymore just run
  • 28:18 - 28:20
    multi-user and we can do that pretty
  • 28:20 - 28:23
    easy um so here i am in my uh my my
  • 28:23 - 28:24
    command prompt and i could be in any
  • 28:24 - 28:26
    prompt it really wouldn't or any folder
  • 28:26 - 28:28
    it wouldn't matter which one i'm gonna
  • 28:28 - 28:31
    do a sudo system systemctl
  • 28:31 - 28:33
    isolate and so i'm telling you i want to
  • 28:33 - 28:36
    to target a specific
  • 28:36 - 28:38
    target that's a little redundant and
  • 28:38 - 28:42
    then i'll just say multi-user.target
  • 28:42 - 28:44
    all right multi-user means yes it's
  • 28:44 - 28:45
    command line but it's not just one
  • 28:45 - 28:47
    console just for you it still allows
  • 28:47 - 28:49
    network services and other things to run
  • 28:49 - 28:51
    and so when i run that
  • 28:51 - 28:53
    see how my system freaked out right it
  • 28:53 - 28:55
    recognized immediately okay we're not
  • 28:55 - 28:57
    going to do the gui target anymore we're
  • 28:57 - 29:00
    going to just do a command line and so
  • 29:00 - 29:01
    now i can come in and i can log in
  • 29:01 - 29:04
    assuming i can remember my password
  • 29:04 - 29:07
    and there we go i'm not in a gui i'm
  • 29:07 - 29:09
    just in the command line and so now if i
  • 29:09 - 29:11
    reboot i'm going to boot just to
  • 29:11 - 29:13
    this interface right here you know this
  • 29:13 - 29:15
    is my actually i need to go and modify
  • 29:15 - 29:16
    my grub
  • 29:16 - 29:18
    loader to tell it exactly what i want um
  • 29:18 - 29:20
    but at this point i'm now in just
  • 29:20 - 29:22
    command line x windows and all the gui
  • 29:22 - 29:24
    stuff is not running at all
  • 29:24 - 29:26
    i can switch back with that same command
  • 29:26 - 29:27
    uh well a little bit different so if i
  • 29:27 - 29:31
    do sudo systemctl isolate and then i'll
  • 29:31 - 29:34
    do graphical.target
  • 29:35 - 29:36
    and that's going to switch me back and
  • 29:36 - 29:37
    now it's loading x window see how it's
  • 29:37 - 29:39
    taking a moment it's not like x windows
  • 29:39 - 29:40
    was running in the background it's got
  • 29:40 - 29:43
    to relaunch all that stuff and get me in
  • 29:43 - 29:45
    here and uh and get me put back in place
  • 29:45 - 29:48
    now because this is happening after my
  • 29:48 - 29:50
    boot operation and all that you see how
  • 29:50 - 29:51
    it's kind of like screwed up my
  • 29:51 - 29:53
    resolution and all that
  • 29:53 - 29:54
    that's one of the trickier parts about
  • 29:54 - 29:56
    moving from one to another if
  • 29:56 - 29:59
    something's not defined in the unit
  • 29:59 - 30:01
    files or some other configuration file
  • 30:01 - 30:03
    then stuff gets lost actually it cleaned
  • 30:03 - 30:06
    up well sort of i got large icons now so
  • 30:06 - 30:08
    so um you know there's there's a lot of
  • 30:08 - 30:10
    people like me if you do this stuff a
  • 30:10 - 30:11
    lot you'll end up writing scripts to
  • 30:11 - 30:13
    kind of automate some of the changes and
  • 30:13 - 30:15
    so for example i have a little script in
  • 30:15 - 30:17
    my home directory
  • 30:17 - 30:18
    this will show you how often i do this
  • 30:18 - 30:21
    to manually set my resolution so that i
  • 30:21 - 30:22
    can just run it real quick
  • 30:22 - 30:24
    and then i'm right back and now my
  • 30:24 - 30:26
    icon's the right size and all so
  • 30:26 - 30:28
    you can switch between targets at the
  • 30:28 - 30:30
    drop of a hat but just know that there
  • 30:30 - 30:31
    are certain penalties to it there's
  • 30:31 - 30:32
    certain things that happen on your
  • 30:32 - 30:33
    system you might not expect so
  • 30:33 - 30:35
    definitely test it out you know run
  • 30:35 - 30:36
    through the routine a few times but
  • 30:36 - 30:38
    that's basically the nuts and bolts of
  • 30:38 - 30:40
    systemd right there there's a lot more
  • 30:40 - 30:42
    to it but the basic operation is there's
  • 30:42 - 30:44
    a ton of text files it reads them and
  • 30:44 - 30:47
    performs as they dictate great episode
  • 30:47 - 30:49
    managing services with system d
  • 30:49 - 30:51
    wonderfully done done and before we move
  • 30:51 - 30:52
    on what else would you like to say uh
  • 30:52 - 30:53
    you know if you want to learn more about
  • 30:53 - 30:55
    systemd definitely check out that
  • 30:55 - 30:57
    there's a systemd website uh it'll be
  • 30:57 - 30:59
    like your first google response i'm sure
  • 30:59 - 31:00
    but there's also a whole suite of other
  • 31:00 - 31:02
    utilities i use systemctl there's
  • 31:02 - 31:04
    journald for the special logging system
  • 31:04 - 31:07
    that systemd uses uh there's hostname
  • 31:07 - 31:08
    ctl for changing your computer hostname
  • 31:08 - 31:10
    there's a number of other ctl commands
  • 31:10 - 31:12
    that are all part of what systemd
  • 31:12 - 31:14
    creates so there's a lot more than we
  • 31:14 - 31:15
    went over in this episode i was just
  • 31:15 - 31:17
    focusing on really what's involved in
  • 31:17 - 31:19
    getting your system up and operational
  • 31:19 - 31:20
    and getting your services running great
  • 31:20 - 31:22
    advice as usual here's some more great
  • 31:22 - 31:24
    advice watch every episode of comtea
  • 31:24 - 31:26
    linux plus you're going to be glad you
  • 31:26 - 31:28
    did it's going to help you now and in
  • 31:28 - 31:30
    the future and keep studying take
  • 31:30 - 31:31
    advantage of the supplementary
  • 31:31 - 31:32
    information in our course library it's
  • 31:32 - 31:35
    there to do one thing help you be even
  • 31:35 - 31:36
    more successful so check that out as
  • 31:36 - 31:38
    well and tell everybody you know about
  • 31:38 - 31:40
    it pro tv you know i t pro tv is binge
  • 31:40 - 31:42
    worthy thanks for watching i'm zach
  • 31:42 - 31:44
    mamas and i'm don pizza and we will see
  • 31:44 - 31:47
    you again soon
  • 31:47 - 31:52
    [Music]
  • 31:52 - 31:57
    thank you for watching it pro tv
  • 31:59 - 32:03
    welcome to it pro tv i'm your host
  • 32:03 - 32:06
    live from san francisco
  • 32:07 - 32:11
    you're watching it pro tv
  • 32:11 - 32:13
    hello thank you for watching it pro tv
  • 32:13 - 32:15
    helping you level up with it learning
  • 32:15 - 32:17
    everywhere you go i'm your host zach
  • 32:17 - 32:19
    memphis for this episode of comptia
  • 32:19 - 32:20
    linux plus
  • 32:20 - 32:23
    managing services with sis v in it is
  • 32:23 - 32:26
    the name of this here episode and don
  • 32:26 - 32:27
    pizzat is going to be showing us the way
  • 32:27 - 32:29
    don good to see you thanks for joining
  • 32:29 - 32:31
    us well glad to be back zach and like i
  • 32:31 - 32:32
    said we're going to be tackling cisv and
  • 32:32 - 32:34
    it you know in the last episode we got a
  • 32:34 - 32:35
    chance to see systemd which is the most
  • 32:35 - 32:38
    popular initialization system in linux
  • 32:38 - 32:40
    right now however if you're working out
  • 32:40 - 32:42
    there in the field there are still many
  • 32:42 - 32:44
    many systems deployed that use the older
  • 32:44 - 32:46
    sysv in it in fact on servers it's
  • 32:46 - 32:48
    actually pretty common so definitely
  • 32:48 - 32:49
    something we want to learn about and
  • 32:49 - 32:50
    that's what we're going to do right here
  • 32:50 - 32:51
    in this episode we're going to learn a
  • 32:51 - 32:53
    little bit about how cisvne how cisvi
  • 32:53 - 32:56
    init works
  • 32:58 - 33:00
    uh we'll see how it works we'll see how
  • 33:00 - 33:02
    to manage it manipulate it and just kind
  • 33:02 - 33:04
    of see how to operate in an environment
  • 33:04 - 33:06
    that is running sysvena fantastic don
  • 33:06 - 33:08
    how are services controlled under linux
  • 33:08 - 33:11
    all right so um basically all of our
  • 33:11 - 33:13
    services inside of linux depend on an
  • 33:13 - 33:15
    initialization of some sort right and
  • 33:15 - 33:17
    system d we've already seen is one way
  • 33:17 - 33:19
    right your system boots up and system d
  • 33:19 - 33:21
    is well kind of follow a boot process
  • 33:21 - 33:24
    right your kernel kicks in and then it
  • 33:24 - 33:26
    launches your init and so system d would
  • 33:26 - 33:27
    launch and then it would control
  • 33:27 - 33:29
    services from there but with csv init
  • 33:29 - 33:31
    it's a little bit different your system
  • 33:31 - 33:33
    boots up your kernel fires up and then
  • 33:33 - 33:36
    the kernel calls a series of scripts cis
  • 33:36 - 33:39
    via init is not a binary execute well i
  • 33:39 - 33:40
    guess it sort of is there's a little bit
  • 33:40 - 33:42
    of a binary but the majority of what it
  • 33:42 - 33:46
    does is all being driven by script files
  • 33:46 - 33:47
    we saw with systemd it was driven by
  • 33:47 - 33:49
    unit files which aren't really scripts
  • 33:49 - 33:50
    they're kind of like descriptions and
  • 33:50 - 33:51
    then systemd knows what to do with it
  • 33:51 - 33:54
    and executes cisvnit just runs scripts
  • 33:54 - 33:55
    whatever happens to be in the script it
  • 33:55 - 33:58
    runs and you can put literally anything
  • 33:58 - 34:00
    in there like starting a service and
  • 34:00 - 34:02
    passing parameters to a service and
  • 34:02 - 34:03
    checking to make sure the service is
  • 34:03 - 34:05
    running or the permissions are set right
  • 34:05 - 34:07
    all of that is different things that
  • 34:07 - 34:10
    cisv and it can do and it does it in a
  • 34:10 - 34:12
    significantly different way than system
  • 34:12 - 34:15
    d does now many people feel the systemd
  • 34:15 - 34:16
    is the
  • 34:16 - 34:18
    better of the two options for modern
  • 34:18 - 34:21
    systems but if you've got a server that
  • 34:21 - 34:24
    millions of users rely upon and it needs
  • 34:24 - 34:26
    to be rock solid cisb and it's been
  • 34:26 - 34:29
    around since the late 1970s early 1980s
  • 34:29 - 34:32
    it's a very stable tried-and-true system
  • 34:32 - 34:34
    and that's why when you go out and look
  • 34:34 - 34:36
    at servers you'll find many still do it
  • 34:36 - 34:37
    let me give you an example if you're
  • 34:37 - 34:40
    deploying linux servers in amazon web
  • 34:40 - 34:42
    services aws they have what's called
  • 34:42 - 34:45
    amazon linux and amazon linux is based
  • 34:45 - 34:48
    off of
  • 34:52 - 34:56
    six which is based on upstart which is
  • 34:56 - 34:58
    based on v in it so it's kind of a long
  • 34:58 - 35:00
    chain so when you go into an amazon
  • 35:00 - 35:03
    linux ami it's going to be using
  • 35:03 - 35:05
    sysvenit initialization strings and all
  • 35:05 - 35:07
    of that so you've got to know it
  • 35:07 - 35:09
    amazon linux 2 which only recently
  • 35:09 - 35:11
    reached production that one now uses
  • 35:11 - 35:13
    systemd so they're moving that direction
  • 35:13 - 35:15
    but most people haven't ported their
  • 35:15 - 35:16
    workload over to it yet so it is very
  • 35:16 - 35:19
    very common to encounter cisvnit systems
  • 35:19 - 35:21
    so how do we know if we are using sysv
  • 35:21 - 35:22
    in it yeah so you know if you've just
  • 35:22 - 35:24
    been hired on somewhere you're taking
  • 35:24 - 35:25
    over a server you might not necessarily
  • 35:25 - 35:27
    know whether it's running sysv in it or
  • 35:27 - 35:29
    not maybe you've got all your distros of
  • 35:29 - 35:31
    version numbers memorized and you just
  • 35:31 - 35:33
    know off bat but if not we can double
  • 35:33 - 35:34
    check you know i mentioned that the
  • 35:34 - 35:36
    kernel is going to fire off the
  • 35:36 - 35:37
    initialization system and that might be
  • 35:37 - 35:38
    systemd
  • 35:38 - 35:41
    or it might be cisv in it well that
  • 35:41 - 35:43
    process of firing off initialization is
  • 35:43 - 35:45
    the very first thing that it does so we
  • 35:45 - 35:47
    can just look at process id number one
  • 35:47 - 35:49
    and that will usually tell us whether
  • 35:49 - 35:52
    we're running system d or cis via init
  • 35:52 - 35:54
    right so for example here let me take
  • 35:54 - 35:56
    this i've got two boxes here this one is
  • 35:56 - 35:59
    a centos 6 box so
  • 35:59 - 36:02
    it's running centos 6.7 which is
  • 36:02 - 36:03
    currently supported so this isn't like
  • 36:03 - 36:05
    this is old and crusty like you can run
  • 36:05 - 36:07
    this in a production environment and if
  • 36:07 - 36:11
    i come in and do a ps aux right
  • 36:11 - 36:14
    and i'm going to just pipe that into the
  • 36:14 - 36:17
    head command so i want to see the first
  • 36:17 - 36:20
    10 lines of my process list when i look
  • 36:20 - 36:22
    at the top processes here process number
  • 36:22 - 36:25
    one right here fired off by root if i
  • 36:25 - 36:26
    come along to the side here i can see
  • 36:26 - 36:29
    that that's slash sbin slash init if it
  • 36:29 - 36:31
    just says that slash spin slash init
  • 36:31 - 36:34
    then odds are you're running sysv in it
  • 36:34 - 36:36
    now it's not a guarantee and that's
  • 36:36 - 36:38
    because
  • 36:38 - 36:40
    some of the os distributions like ubuntu
  • 36:40 - 36:42
    ubuntu will actually show slash s bin
  • 36:42 - 36:44
    slash init also
  • 36:44 - 36:46
    but when you go and look at that binary
  • 36:46 - 36:50
    if you do an ls dash l slash sbin slash
  • 36:50 - 36:52
    init when you look at the binary on an
  • 36:52 - 36:55
    ubuntu system on a newer ubuntu system
  • 36:55 - 36:57
    it will actually be a sim link
  • 36:57 - 37:00
    pointing to system d right so be careful
  • 37:00 - 37:02
    with this one in fact if i go to like my
  • 37:02 - 37:05
    here's a centos 7 box
  • 37:05 - 37:07
    let me get into a terminal here and i'll
  • 37:07 - 37:10
    do the same kind of thing with ps aux
  • 37:10 - 37:12
    and i'll pipe that into head
  • 37:12 - 37:15
    and that very first process i can see
  • 37:15 - 37:17
    right here is pointing to slash user
  • 37:17 - 37:20
    slash lib systemd systemd so this is
  • 37:20 - 37:23
    pretty obvious right ubuntu at least in
  • 37:23 - 37:25
    the newest ones in the 18 releases
  • 37:25 - 37:26
    they're a little bit trickier so always
  • 37:26 - 37:27
    be on the lookout for that but that's
  • 37:27 - 37:30
    probably the easiest way to tell whether
  • 37:30 - 37:32
    you're running cis via init or not so
  • 37:32 - 37:34
    what you're looking for is that slash s
  • 37:34 - 37:36
    bin slash init that tells you what
  • 37:36 - 37:37
    you're running um and once you've got
  • 37:37 - 37:39
    that figured out now you know that you
  • 37:39 - 37:40
    need to administer this system a
  • 37:40 - 37:42
    slightly different way than you would a
  • 37:42 - 37:44
    systemd system so
  • 37:44 - 37:46
    sis v and it starts right after the
  • 37:46 - 37:48
    kernel right so then what happens all
  • 37:48 - 37:50
    right so cispean it does have a binary
  • 37:50 - 37:52
    right so it's slash s bin slash in it
  • 37:52 - 37:55
    right so our our bios fires up on the
  • 37:55 - 37:56
    system and it does all the hardware
  • 37:56 - 37:59
    detection then it reaches out it finds a
  • 37:59 - 38:00
    hard drive partition it finds the slash
  • 38:00 - 38:02
    boot partition finds the kernel launches
  • 38:02 - 38:05
    the kernel the kernel then turns around
  • 38:05 - 38:08
    and says okay i'm a sisvie init system
  • 38:08 - 38:11
    and it launches slash spin slash init
  • 38:11 - 38:12
    and when it does
  • 38:12 - 38:15
    it then proceeds to start launching a
  • 38:15 - 38:17
    series of scripts that that init
  • 38:17 - 38:19
    executable is then just going to run a
  • 38:19 - 38:21
    series of scripts and it runs them in
  • 38:21 - 38:23
    serial not in parallel system d does
  • 38:23 - 38:25
    stuff in parallel it'll do more than one
  • 38:25 - 38:27
    thing at the same time but with sysv
  • 38:27 - 38:30
    init it runs one script at a time and
  • 38:30 - 38:31
    when it finishes then it runs the next
  • 38:31 - 38:33
    one when that's done then it runs the
  • 38:33 - 38:35
    next one and so on and it all kicks off
  • 38:35 - 38:37
    with one script let me show you here on
  • 38:37 - 38:39
    this system if you go into
  • 38:39 - 38:41
    etc
  • 38:41 - 38:43
    you'll find a folder in there
  • 38:43 - 38:44
    called
  • 38:44 - 38:48
    rc.d this folder right here now this
  • 38:48 - 38:50
    folder has changed a lot over the years
  • 38:50 - 38:51
    originally there were there were
  • 38:51 - 38:53
    different folders in fact see all these
  • 38:53 - 38:57
    light blue folders up here yeah rc rc0.d
  • 38:57 - 39:00
    rc.local rc.assistant all these are like
  • 39:00 - 39:03
    previous iterations of what uh
  • 39:03 - 39:06
    uh of what cis vienna or like system
  • 39:06 - 39:08
    four init or system three in it like
  • 39:08 - 39:09
    each of them kind of relied on different
  • 39:09 - 39:10
    folders they're there for backwards
  • 39:10 - 39:12
    compatibility but now pretty much
  • 39:12 - 39:15
    everything is tucked away inside of rc.d
  • 39:15 - 39:18
    and if we go into that folder
  • 39:18 - 39:20
    and look you'll see a number of
  • 39:20 - 39:22
    subfolders based on all sorts of
  • 39:22 - 39:24
    different stuff and each one of these
  • 39:24 - 39:26
    kind of influences what sysvnit does
  • 39:26 - 39:28
    when it launches and the main one that
  • 39:28 - 39:30
    we want to pay attention to is this guy
  • 39:30 - 39:33
    right here rc dot system it
  • 39:33 - 39:36
    when cis v and it starts this is the
  • 39:36 - 39:38
    first thing that it calls it reaches out
  • 39:38 - 39:40
    to this script and it executes it and
  • 39:40 - 39:44
    then from there it will proceed to
  • 39:44 - 39:46
    spawn other things and there's a lot of
  • 39:46 - 39:47
    things that influence what it's going to
  • 39:47 - 39:50
    spawn uh which are all kind of tied to
  • 39:50 - 39:52
    uh parts of what it does but this one's
  • 39:52 - 39:54
    really the heart and soul of it so
  • 39:54 - 39:55
    sis
  • 39:55 - 39:57
    slash spin slash and it runs and it
  • 39:57 - 39:59
    calls this script to then initialize the
  • 39:59 - 40:01
    system does that one script then call
  • 40:01 - 40:04
    other scripts absolutely yep so uh it it
  • 40:04 - 40:07
    runs and as it's finishing it's then
  • 40:07 - 40:08
    launching other things based on a
  • 40:08 - 40:10
    certain criteria right and that criteria
  • 40:10 - 40:12
    is what's called a run level so notice
  • 40:12 - 40:13
    all these other folders over here
  • 40:13 - 40:16
    rc0.d1.d2.d
  • 40:16 - 40:18
    those are are tied to run levels right
  • 40:18 - 40:20
    so in in linux you have seven run levels
  • 40:20 - 40:22
    and each one indicates a different
  • 40:22 - 40:24
    status of the machine so for example
  • 40:24 - 40:26
    zero actually means the system is shut
  • 40:26 - 40:27
    down
  • 40:27 - 40:30
    now you might wonder to yourself there
  • 40:30 - 40:31
    like
  • 40:31 - 40:32
    why would i have a run level for
  • 40:32 - 40:33
    shutdown well you got to tell the system
  • 40:33 - 40:35
    to shut down and you might actually have
  • 40:35 - 40:36
    scripts that are a part of that when
  • 40:36 - 40:39
    your system is shutting down it needs to
  • 40:39 - 40:40
    you know basically
  • 40:40 - 40:43
    perform a few tasks maybe you know stop
  • 40:43 - 40:45
    rights to the hard disk or so on and
  • 40:45 - 40:47
    close out what it's doing and those will
  • 40:47 - 40:49
    be part of the shutdown script you also
  • 40:49 - 40:50
    have
  • 40:50 - 40:53
    rc6 here which is reboot and so that's
  • 40:53 - 40:55
    when your system is rebooting it might
  • 40:55 - 40:56
    have certain tests they might be the
  • 40:56 - 40:57
    same they might be totally empty there
  • 40:57 - 40:59
    might be no tasks tied to reboot and
  • 40:59 - 41:00
    shutdown but that's what those run
  • 41:00 - 41:03
    levels are the other run levels
  • 41:03 - 41:05
    are kind of up to the distro that they
  • 41:05 - 41:08
    can operate in different modes and
  • 41:08 - 41:10
    they've they've kind of standardized on
  • 41:10 - 41:12
    it so most of the distros follow the
  • 41:12 - 41:14
    same pattern but it's not a guarantee so
  • 41:14 - 41:16
    always be careful if you're not sure
  • 41:16 - 41:18
    check your distro's documentation a lot
  • 41:18 - 41:19
    of them
  • 41:19 - 41:22
    will document what their run levels are
  • 41:22 - 41:24
    in their initialization table so there's
  • 41:24 - 41:27
    a file if i i'm just going to cat slash
  • 41:27 - 41:28
    etc
  • 41:28 - 41:31
    init tab that's the initialization table
  • 41:31 - 41:33
    and when you look in that file most
  • 41:33 - 41:35
    distros do take the time to document the
  • 41:35 - 41:36
    run levels and so i can see right here
  • 41:36 - 41:40
    for centos and this applies to uh centos
  • 41:40 - 41:42
    and red hat enterprise linux i can see
  • 41:42 - 41:43
    the seven run levels so see how the zero
  • 41:43 - 41:46
    is halt halt is when the computer's
  • 41:46 - 41:49
    turned off uh and then six is reboot one
  • 41:49 - 41:52
    is single user mode that means that only
  • 41:52 - 41:54
    one user can be logged into the system
  • 41:54 - 41:56
    and nobody else can be logged in right
  • 41:56 - 41:58
    that's actually pretty handy if you're
  • 41:58 - 41:59
    an administrator sometimes you want to
  • 41:59 - 42:01
    modify a file but it's always in use
  • 42:01 - 42:03
    somebody's accessing it or there's a
  • 42:03 - 42:04
    file share people are accessing it over
  • 42:04 - 42:06
    the network you need to make sure you
  • 42:06 - 42:07
    have exclusive access to it so you can
  • 42:07 - 42:09
    boot in single user mode and you know
  • 42:09 - 42:12
    you'll have that there's multi-user
  • 42:12 - 42:14
    without it says without nfs it's
  • 42:14 - 42:16
    actually multi-user without networking
  • 42:16 - 42:18
    so it boots up in the full mode but with
  • 42:18 - 42:20
    no networking services at all and that
  • 42:20 - 42:21
    way you can ensure nobody over the
  • 42:21 - 42:23
    network is getting into the system if
  • 42:23 - 42:25
    you think you've been hacked here's a
  • 42:25 - 42:26
    great way to boot and shut off your
  • 42:26 - 42:28
    network and now you can get in and
  • 42:28 - 42:30
    examine the system and you know you're
  • 42:30 - 42:31
    not communicating out
  • 42:31 - 42:34
    you have full multi-user mode which is
  • 42:34 - 42:35
    run level three and that's where you're
  • 42:35 - 42:38
    saying look i want to boot up to a
  • 42:38 - 42:40
    command line interface
  • 42:40 - 42:41
    but i'm allowing multiple users people
  • 42:41 - 42:43
    can ssh in or i have more than one
  • 42:43 - 42:45
    console so a lot of people can be
  • 42:45 - 42:47
    working in the system that's the run
  • 42:47 - 42:49
    level that most servers run at
  • 42:49 - 42:51
    run level four it's actually not used i
  • 42:51 - 42:53
    i don't think i've seen a distro yet
  • 42:53 - 42:55
    that makes use of it but it's available
  • 42:55 - 42:56
    so if you want to create a custom run
  • 42:56 - 42:58
    level that's usually what run level 4 is
  • 42:58 - 43:00
    reserved for
  • 43:00 - 43:02
    run level 5 it's labeled here as x11 but
  • 43:02 - 43:04
    that means we want to boot a gui we want
  • 43:04 - 43:06
    to boot a graphical user interface which
  • 43:06 - 43:07
    is typically the x environment but you
  • 43:07 - 43:09
    know you might have some alternate user
  • 43:09 - 43:10
    interface
  • 43:10 - 43:12
    and that one is multi-user with
  • 43:12 - 43:14
    networking and a gui so it's kind of
  • 43:14 - 43:16
    like the
  • 43:16 - 43:17
    the full shebang right it boots
  • 43:17 - 43:19
    everything and then you get access to
  • 43:19 - 43:21
    the system so those are the run levels
  • 43:21 - 43:22
    and
  • 43:22 - 43:25
    looking at this slash etc rcd dot d
  • 43:25 - 43:27
    folders kind of hard to say
  • 43:27 - 43:31
    all these subfolders rc1.d rc2.d these
  • 43:31 - 43:34
    contain scripts so when i boot into
  • 43:34 - 43:38
    multi-user mode command line only
  • 43:38 - 43:40
    rc dot system it is going to run and
  • 43:40 - 43:43
    then it's going to look in rc3.d
  • 43:43 - 43:44
    and it's going to look at what scripts
  • 43:44 - 43:46
    are in there and look at all these
  • 43:46 - 43:47
    scripts that i've got i've got where
  • 43:47 - 43:49
    it's starting the quota daemon and
  • 43:49 - 43:52
    iptables for the firewall the lvm
  • 43:52 - 43:54
    monitor for my logical volume manager uh
  • 43:54 - 43:56
    network manager is starting postfix all
  • 43:56 - 43:58
    these different things will start when
  • 43:58 - 44:00
    my system starts these are tied to
  • 44:00 - 44:02
    various services right postfix uh that's
  • 44:02 - 44:04
    an email service
  • 44:04 - 44:07
    ssjshd that's my secure shell daemon
  • 44:07 - 44:09
    these are all being started that's how
  • 44:09 - 44:11
    it knows what services to fire up and
  • 44:11 - 44:13
    it's all controlled by the run level if
  • 44:13 - 44:17
    i look in uh let's go into rc
  • 44:17 - 44:19
    5.d
  • 44:19 - 44:20
    all right so this is if i boot with a
  • 44:20 - 44:21
    full gui
  • 44:21 - 44:22
    and i'll see things are a little bit
  • 44:22 - 44:24
    different there's a lot of overlap right
  • 44:24 - 44:26
    so i still see sshd right there i still
  • 44:26 - 44:29
    see post fix right but i'll also see
  • 44:29 - 44:31
    some things in here that are tied to
  • 44:31 - 44:33
    x windows let's see i should be seeing
  • 44:33 - 44:36
    gdm in here somewhere i must be skimming
  • 44:36 - 44:37
    over it
  • 44:37 - 44:38
    it's hard when you're under pressure on
  • 44:38 - 44:40
    the show but somewhere in here is gdm
  • 44:40 - 44:42
    which starts the graphical device uh
  • 44:42 - 44:43
    device manager they have to let you get
  • 44:43 - 44:45
    logged in and all of that so it's
  • 44:45 - 44:47
    additional things that will get loaded
  • 44:47 - 44:48
    you may see variations depending on
  • 44:48 - 44:51
    which run level you boot that's what all
  • 44:51 - 44:53
    happens right here
  • 44:53 - 44:56
    then there's one more thing that may not
  • 44:56 - 44:59
    get loaded but typically doesn't uh back
  • 44:59 - 45:00
    in rc.d
  • 45:00 - 45:02
    there's one more file
  • 45:02 - 45:06
    rc.local okay on really old systems i'm
  • 45:06 - 45:08
    talking unix all right
  • 45:08 - 45:11
    it would run rc.systenit
  • 45:11 - 45:13
    then it would run all the scripts for
  • 45:13 - 45:15
    the run level and then last it would run
  • 45:15 - 45:18
    rc.local and that was your way to
  • 45:18 - 45:19
    override anything else that was run
  • 45:19 - 45:22
    before you kind of undo or redo stuff
  • 45:22 - 45:24
    most distros
  • 45:24 - 45:25
    have the file for backwards
  • 45:25 - 45:27
    compatibility but don't do anything with
  • 45:27 - 45:29
    it so it's usually empty or it may not
  • 45:29 - 45:30
    even be called at all you'd have to
  • 45:30 - 45:32
    check your run level scripts to see if
  • 45:32 - 45:35
    they return to it or check rc.cisnet so
  • 45:35 - 45:37
    like if i take a look at my rc.local
  • 45:37 - 45:40
    let's see what's in it um yeah it's
  • 45:40 - 45:42
    pretty much empty in fact it just uh
  • 45:42 - 45:43
    touches a file to indicate that it's
  • 45:43 - 45:45
    locked and that's it so
  • 45:45 - 45:47
    it's not used in this case but it is
  • 45:47 - 45:49
    there so if you want to make use of it
  • 45:49 - 45:52
    you can versus if i take a look at
  • 45:52 - 45:54
    rc.systenit
  • 45:54 - 45:55
    and take a look at that one there's all
  • 45:55 - 45:56
    sorts of stuff in here as it goes
  • 45:56 - 45:58
    through mounting your disks or turning
  • 45:58 - 46:01
    on se linux right there uh you know
  • 46:01 - 46:03
    doing all sorts of other stuff this is a
  • 46:03 - 46:05
    big deal right it's got a lot of work to
  • 46:05 - 46:08
    do rc.local is empty
  • 46:08 - 46:09
    do we have to modify the script files
  • 46:09 - 46:12
    for each uh run level when we install a
  • 46:12 - 46:13
    service
  • 46:13 - 46:14
    all right so a good question right so i
  • 46:14 - 46:16
    showed where sshd was in there right so
  • 46:16 - 46:18
    my ssh demon is starting automatically
  • 46:18 - 46:19
    and it's in more than one run level
  • 46:19 - 46:21
    right so if i install a service like
  • 46:21 - 46:24
    let's say i want to install a web server
  • 46:24 - 46:26
    right so i'm going to install apache and
  • 46:26 - 46:28
    when i install apache i want it to run
  • 46:28 - 46:31
    on my system boots okay well
  • 46:31 - 46:33
    if you notice with ssh it was set to
  • 46:33 - 46:35
    start at run level three and it was set
  • 46:35 - 46:37
    to start at run level five uh they
  • 46:37 - 46:38
    skipped run level four because it's not
  • 46:38 - 46:40
    used and they skipped run level two
  • 46:40 - 46:41
    because run level two boots with no
  • 46:41 - 46:43
    networking so why why bother starting a
  • 46:43 - 46:45
    web server if there's no networking
  • 46:45 - 46:46
    right
  • 46:46 - 46:48
    or ssh in that case
  • 46:48 - 46:49
    i might want a web server to do the same
  • 46:49 - 46:50
    thing so i want the web server to start
  • 46:50 - 46:53
    with run level three and run level five
  • 46:53 - 46:56
    so to do that i mean we could manually
  • 46:56 - 46:57
    create scripts and put them in there but
  • 46:57 - 46:59
    what you'll find is that most of this is
  • 46:59 - 47:01
    handled for us through a handful of
  • 47:01 - 47:03
    commands all right let me let me just
  • 47:03 - 47:05
    show you kind of how this works so on my
  • 47:05 - 47:08
    system i'm going to do a sudo yum
  • 47:08 - 47:10
    install httpd all right so i'm going to
  • 47:10 - 47:13
    install apache right
  • 47:13 - 47:14
    and apparently it's already installed
  • 47:14 - 47:16
    great
  • 47:16 - 47:19
    so i've already got it installed now
  • 47:19 - 47:20
    once it's installed you can go through
  • 47:20 - 47:24
    and create scripts so if i go back to uh
  • 47:24 - 47:25
    let's see
  • 47:25 - 47:27
    rc3.d
  • 47:27 - 47:29
    and take a look in here i don't recall
  • 47:29 - 47:31
    seeing http in the list oh it is right
  • 47:31 - 47:32
    there
  • 47:32 - 47:35
    k15 httpd so i've already got it
  • 47:35 - 47:36
    installed and it's already set to start
  • 47:36 - 47:38
    so i picked a bad example all right
  • 47:38 - 47:40
    let's do uh maybe we'll do a database
  • 47:40 - 47:42
    instead is mysql on here let me just
  • 47:42 - 47:43
    skim the list and make sure i don't make
  • 47:43 - 47:44
    the same mistake twice all right we'll
  • 47:44 - 47:47
    do mysql so i'm going to do a sudo yum
  • 47:47 - 47:49
    install
  • 47:49 - 47:50
    mysql
  • 47:50 - 47:53
    and i'll do mysql-server as well and
  • 47:53 - 47:54
    we'll do a dash-y so it just does it all
  • 47:54 - 47:56
    right so it's going to install the
  • 47:56 - 47:58
    database server now when the database
  • 47:58 - 48:01
    server is installed it's not set to run
  • 48:01 - 48:02
    automatically or at least it shouldn't
  • 48:02 - 48:04
    be so i'm going to pull a list back up
  • 48:04 - 48:06
    here and look
  • 48:06 - 48:08
    and i do see it actually created a link
  • 48:08 - 48:11
    right there so it's smart enough to
  • 48:11 - 48:13
    create the links with what the default
  • 48:13 - 48:16
    run level should be if we want it on
  • 48:16 - 48:18
    three and we want it on five it shows up
  • 48:18 - 48:20
    right there now
  • 48:20 - 48:22
    what if that's not what we want though i
  • 48:22 - 48:25
    don't want mysql to run maybe i i only
  • 48:25 - 48:27
    want it to run when my gui is running
  • 48:27 - 48:29
    but i don't want it to run when i'm
  • 48:29 - 48:31
    booting to command line only or you know
  • 48:31 - 48:33
    something crazy like that right well you
  • 48:33 - 48:34
    can actually manipulate these pretty
  • 48:34 - 48:36
    easy without having to write or even
  • 48:36 - 48:39
    edit the scripts at all right so you
  • 48:39 - 48:40
    certainly can come in here most of these
  • 48:40 - 48:41
    are just sim links see how they're light
  • 48:41 - 48:44
    blue if you uh pull up a long listing
  • 48:44 - 48:46
    you'll see they're almost all sim linked
  • 48:46 - 48:48
    to the init.d folder
  • 48:48 - 48:50
    and in there is where these text files
  • 48:50 - 48:52
    are kind of being created but we can
  • 48:52 - 48:54
    manipulate all of this a few different
  • 48:54 - 48:55
    ways
  • 48:55 - 48:58
    the easiest way is to use the check
  • 48:58 - 49:00
    config command chk
  • 49:00 - 49:03
    co and fig check config what check
  • 49:03 - 49:05
    config does is it lets you turn services
  • 49:05 - 49:08
    on or off for different run levels
  • 49:08 - 49:11
    it defaults to run level three and five
  • 49:11 - 49:14
    so if i do a check config
  • 49:14 - 49:15
    and then i say
  • 49:15 - 49:18
    httpd on
  • 49:18 - 49:19
    that's going to turn oop i need to sue
  • 49:19 - 49:20
    do that let me do that command there
  • 49:20 - 49:23
    there we go that's going to turn on
  • 49:23 - 49:27
    httpd for run levels 3 and 5. if i boot
  • 49:27 - 49:29
    at run level 1 or 2 or 4 it's not going
  • 49:29 - 49:32
    to start but 3 and 5 it will
  • 49:32 - 49:34
    and that's kind of its default operation
  • 49:34 - 49:35
    if i say off
  • 49:35 - 49:38
    then httpd is not going to start in run
  • 49:38 - 49:40
    level anything right it's going to turn
  • 49:40 - 49:42
    them all off right but i can go a step
  • 49:42 - 49:43
    further with this command and i can be
  • 49:43 - 49:46
    really specific i can say for example
  • 49:46 - 49:48
    check config httpd
  • 49:48 - 49:50
    dash dash level
  • 49:50 - 49:52
    and then specify the levels i want the
  • 49:52 - 49:54
    default would be three five like that so
  • 49:54 - 49:56
    run levels three and five that's where
  • 49:56 - 49:57
    it's going to start maybe i want it to
  • 49:57 - 49:59
    run well i'll just leave it at 3 and 5.
  • 49:59 - 50:00
    let's take
  • 50:00 - 50:02
    mysql
  • 50:02 - 50:03
    oops
  • 50:03 - 50:06
    sorry i have to do one more option here
  • 50:06 - 50:08
    and say on there
  • 50:08 - 50:10
    so i left off a little on tag so it got
  • 50:10 - 50:11
    unhappy with me
  • 50:11 - 50:13
    let's say that i want mysql to run in
  • 50:13 - 50:17
    run level three and run level five and
  • 50:17 - 50:19
    run level two right mysql actually
  • 50:19 - 50:21
    doesn't need the network in a
  • 50:21 - 50:23
    traditional sense you can use name pipes
  • 50:23 - 50:24
    to access it so maybe i want that
  • 50:24 - 50:26
    database up and running even when the
  • 50:26 - 50:29
    network stack isn't up and going so for
  • 50:29 - 50:31
    that one i could do a sudo check config
  • 50:31 - 50:34
    dash dash level 235
  • 50:34 - 50:37
    mysqld on
  • 50:37 - 50:39
    and now it's set to go with multiple run
  • 50:39 - 50:41
    levels so it's kind of a cool one
  • 50:41 - 50:43
    it's easy to lose track of this stuff
  • 50:43 - 50:44
    though and we could go and sift through
  • 50:44 - 50:46
    the scripts and figure out where it's
  • 50:46 - 50:47
    set to run and where it's set not to so
  • 50:47 - 50:50
    if i go into uh
  • 50:50 - 50:53
    slash etc rc.d slash
  • 50:53 - 50:56
    rc2.d and take a look in there i can
  • 50:56 - 50:57
    find
  • 50:57 - 50:59
    wait a minute http is in the list
  • 50:59 - 51:01
    right it's actually sim linking to all
  • 51:01 - 51:03
    of these but the script is telling it
  • 51:03 - 51:05
    only to run at a certain run level and
  • 51:05 - 51:06
    that run level is left off so if we try
  • 51:06 - 51:08
    and track it right here through these
  • 51:08 - 51:09
    sim links
  • 51:09 - 51:11
    it really doesn't help we don't actually
  • 51:11 - 51:13
    know if it's going to start or not so a
  • 51:13 - 51:14
    better way to figure out what's going to
  • 51:14 - 51:16
    start and what isn't is to use check
  • 51:16 - 51:19
    config dash dash list
  • 51:19 - 51:21
    and that's going to list your services
  • 51:21 - 51:23
    and tell you what run levels they're
  • 51:23 - 51:25
    going to execute at so if i run that i
  • 51:25 - 51:27
    get this nice big list right here
  • 51:27 - 51:31
    and it's got all seven run levels with a
  • 51:31 - 51:34
    simple on or off next to each one so i
  • 51:34 - 51:38
    can find http right uh whoops
  • 51:38 - 51:41
    if i can scroll back up to it i can find
  • 51:41 - 51:42
    it right here
  • 51:42 - 51:44
    and the mouse is my biggest challenge
  • 51:44 - 51:45
    with this stuff
  • 51:45 - 51:47
    and i can see run levels one
  • 51:47 - 51:50
    zero one and two it's off run level 3 is
  • 51:50 - 51:53
    on 4 is off 5 is on 6 is off so just 3
  • 51:53 - 51:57
    and 5 are on even though i saw an httpd
  • 51:57 - 51:59
    link in slash etc
  • 51:59 - 52:03
    rc.d slash rc2.d and if i look at mysql
  • 52:03 - 52:05
    right here
  • 52:05 - 52:07
    i can see that it's a little different
  • 52:07 - 52:09
    in that it's two three and five that are
  • 52:09 - 52:12
    all turned on okay this is a better way
  • 52:12 - 52:14
    to see what's being run at each run
  • 52:14 - 52:15
    level if you just look at the links you
  • 52:15 - 52:17
    can't tell you'd have to follow the link
  • 52:17 - 52:19
    and then you have to edit the script or
  • 52:19 - 52:20
    at least view the script that it links
  • 52:20 - 52:22
    to and in that script it'll have an if
  • 52:22 - 52:24
    statement at the beginning that says
  • 52:24 - 52:26
    like if run level equals and it'll list
  • 52:26 - 52:28
    the run levels where it's going to start
  • 52:28 - 52:29
    that's a pain
  • 52:29 - 52:31
    check config dash list you'll see it all
  • 52:31 - 52:33
    right there and if you have a huge list
  • 52:33 - 52:35
    you can always pipe that into the grep
  • 52:35 - 52:37
    command and once it's in the grip
  • 52:37 - 52:39
    command uh
  • 52:39 - 52:41
    you can just say like i'm looking for
  • 52:41 - 52:43
    mysql and then you just get that one
  • 52:43 - 52:44
    line that makes life a little bit easier
  • 52:44 - 52:47
    there so pretty easy to verify uh we
  • 52:47 - 52:48
    could also just do it manually like
  • 52:48 - 52:50
    maybe maybe i'm not so concerned about
  • 52:50 - 52:51
    when the system starts i just need to
  • 52:51 - 52:53
    use my sql for a little while right now
  • 52:53 - 52:55
    okay so for that you'll use the service
  • 52:55 - 52:59
    command and we can just come in and say
  • 52:59 - 53:01
    sudo service
  • 53:01 - 53:03
    and then start and whatever the services
  • 53:03 - 53:04
    we want to start if i want to start
  • 53:04 - 53:07
    httpd there we go uh oops i got it
  • 53:07 - 53:10
    backwards uh service
  • 53:10 - 53:12
    httpd start
  • 53:12 - 53:13
    there we go
  • 53:13 - 53:15
    sorry you got to say the service name
  • 53:15 - 53:16
    first and start second i got it
  • 53:16 - 53:20
    backwards so sudo service start httpd
  • 53:20 - 53:22
    and now it starts up and i can do the
  • 53:22 - 53:24
    same thing with like mysqld which it'll
  • 53:24 - 53:25
    probably be unhappy that i haven't
  • 53:25 - 53:27
    secured it yet but we'll do it anyway
  • 53:27 - 53:29
    we can start that one up yeah it's
  • 53:29 - 53:30
    warning me that i need to run the
  • 53:30 - 53:32
    security startup script but uh but there
  • 53:32 - 53:34
    it goes so now those two services are
  • 53:34 - 53:35
    running
  • 53:35 - 53:36
    but
  • 53:36 - 53:38
    let's say i'm at run level five right
  • 53:38 - 53:40
    now and those are up and running and i
  • 53:40 - 53:42
    reboot my system if those aren't set to
  • 53:42 - 53:43
    start with run level five they won't be
  • 53:43 - 53:45
    started when i reboot so using the
  • 53:45 - 53:46
    service command like this is not
  • 53:46 - 53:48
    permanent it's really just kind of a
  • 53:48 - 53:51
    temporary thing just to get uh get the
  • 53:51 - 53:53
    service up and running and so on and you
  • 53:53 - 53:55
    can do a service
  • 53:55 - 53:56
    status
  • 53:56 - 53:58
    for any service
  • 53:58 - 54:00
    and take a look at like hdbd
  • 54:00 - 54:01
    and
  • 54:01 - 54:02
    oops
  • 54:02 - 54:05
    backwards again darn it service httpd
  • 54:05 - 54:07
    status there we go
  • 54:07 - 54:09
    and if we do that when i'll get it right
  • 54:09 - 54:10
    eventually we can see if the service is
  • 54:10 - 54:12
    actually actively running right now you
  • 54:12 - 54:14
    may find where it started with the
  • 54:14 - 54:16
    script and then something went wrong and
  • 54:16 - 54:18
    it closed and so even though rc.d is
  • 54:18 - 54:20
    telling it yeah you need to start this
  • 54:20 - 54:22
    at boot it may not be booted so this is
  • 54:22 - 54:24
    a good way to quick check that
  • 54:24 - 54:26
    and see and i'll do the same thing with
  • 54:26 - 54:28
    mysqld and i can verify right there
  • 54:28 - 54:31
    they're both up and running and happy
  • 54:31 - 54:32
    down how does this v in it know which
  • 54:32 - 54:34
    run level to boot to
  • 54:34 - 54:36
    uh you know i glanced over it earlier so
  • 54:36 - 54:38
    we kind of have some defaults right
  • 54:38 - 54:39
    where we're saying boot to the graphical
  • 54:39 - 54:41
    user interface or boot to the command
  • 54:41 - 54:43
    line uh and your your os your
  • 54:43 - 54:44
    distribution will typically default to
  • 54:44 - 54:47
    one or the other that comes from the
  • 54:47 - 54:49
    slash etc init tab folder that our file
  • 54:49 - 54:51
    that i opened earlier uh if i cat that
  • 54:51 - 54:53
    one slash etc
  • 54:53 - 54:56
    init tab all right so this is the file i
  • 54:56 - 54:58
    brought up on screen earlier to show the
  • 54:58 - 55:00
    run levels well there's one tiny little
  • 55:00 - 55:01
    line at the very end that i didn't
  • 55:01 - 55:03
    mention this this guy right here that
  • 55:03 - 55:05
    says id colon
  • 55:05 - 55:09
    5 colon init default colon all right so
  • 55:09 - 55:11
    this is telling the system what run
  • 55:11 - 55:13
    level to boot to by default so mine is
  • 55:13 - 55:16
    at the default to run level 5 which is a
  • 55:16 - 55:18
    full graphical user interface if i'm
  • 55:18 - 55:20
    setting up a server i probably don't
  • 55:20 - 55:22
    want the gui so i'll tell it to boot to
  • 55:22 - 55:24
    the command line to boot to multi-user
  • 55:24 - 55:25
    mode which is run level three so to do
  • 55:25 - 55:27
    that i would just edit this file and
  • 55:27 - 55:29
    change that five to a three and then
  • 55:29 - 55:31
    when you reboot it's gonna boot to the
  • 55:31 - 55:32
    command line and when you're ready you
  • 55:32 - 55:33
    can always change it back to a five
  • 55:33 - 55:36
    again and it'll boot up and and that'll
  • 55:36 - 55:37
    be kind of the the run level that it
  • 55:37 - 55:39
    goes to now that's if i want to make a
  • 55:39 - 55:41
    permanent change
  • 55:41 - 55:42
    let's say it's just a temporary thing
  • 55:42 - 55:44
    right maybe i'm having some kind of
  • 55:44 - 55:48
    crazy issues with x windows and
  • 55:48 - 55:49
    i just want to
  • 55:49 - 55:50
    to dump out and get rid of all of x
  • 55:50 - 55:52
    windows and then come back into x
  • 55:52 - 55:53
    windows but not
  • 55:53 - 55:54
    kind of not have to restart all my
  • 55:54 - 55:57
    services or whatever so we can actually
  • 55:57 - 55:59
    change the run level whenever we want
  • 55:59 - 56:01
    while the system is running now it can
  • 56:01 - 56:02
    have disastrous effects so we need to be
  • 56:02 - 56:03
    a little bit careful with it you know
  • 56:03 - 56:05
    all these scripts are going to execute
  • 56:05 - 56:06
    and do stuff
  • 56:06 - 56:08
    but if you ever want to change your run
  • 56:08 - 56:10
    level just temporarily there's a command
  • 56:10 - 56:12
    you can run which is init
  • 56:12 - 56:14
    if you run init
  • 56:14 - 56:15
    followed by a number let me pull out the
  • 56:15 - 56:18
    man file for that so if you just run
  • 56:18 - 56:19
    init followed by a number it will
  • 56:19 - 56:22
    immediately change your system
  • 56:22 - 56:24
    into whatever that other
  • 56:24 - 56:26
    init level happens to be now if you're
  • 56:26 - 56:28
    going to do this be really careful of
  • 56:28 - 56:30
    other users in the system you can you
  • 56:30 - 56:31
    can really mess with them especially if
  • 56:31 - 56:33
    you're about to drop a single user mode
  • 56:33 - 56:35
    so you might want to use the who command
  • 56:35 - 56:37
    to see who's logged in and how they're
  • 56:37 - 56:38
    accessing the system to say all right
  • 56:38 - 56:40
    here's people i need to contact before i
  • 56:40 - 56:42
    change this run level but assuming
  • 56:42 - 56:44
    you're the only one in here let me take
  • 56:44 - 56:46
    this system and i'm going to go to
  • 56:46 - 56:47
    multi-user mode right so i'm going to
  • 56:47 - 56:50
    say sudo init three i want to drop to
  • 56:50 - 56:53
    run level three and when i run that
  • 56:53 - 56:55
    my system drops to the itsy-weensy tiny
  • 56:55 - 56:56
    little console
  • 56:56 - 56:59
    and so i get to see that and we get out
  • 56:59 - 57:01
    the magnifying glass yeah yeah we'd have
  • 57:01 - 57:03
    to use it here uh so we lose all the you
  • 57:03 - 57:04
    know the cool
  • 57:04 - 57:05
    um
  • 57:05 - 57:06
    uh
  • 57:06 - 57:08
    screen enhancements and so on and now
  • 57:08 - 57:11
    we're just in straight command line mode
  • 57:11 - 57:13
    and there we are right so now i'm kind
  • 57:13 - 57:14
    of operating in this
  • 57:14 - 57:17
    this different world x windows has been
  • 57:17 - 57:19
    completely unloaded and it's executed
  • 57:19 - 57:22
    the scripts found in that rc3.d folder
  • 57:22 - 57:25
    to move me into this kind of mode and i
  • 57:25 - 57:28
    can switch back if i want by saying init
  • 57:28 - 57:30
    well i gotta sue do that sudo in it
  • 57:30 - 57:32
    and then move back into run level five
  • 57:32 - 57:35
    and when i run that
  • 57:35 - 57:36
    there we go i see that it takes me back
  • 57:36 - 57:38
    to my centos login screen
  • 57:38 - 57:41
    and i can get logged back in
  • 57:41 - 57:43
    and now i'm back into the gui so we
  • 57:43 - 57:45
    quickly and easily change our run level
  • 57:45 - 57:47
    like that now uh
  • 57:47 - 57:49
    most of the time we're going to do it
  • 57:49 - 57:50
    just like i did right there it's going
  • 57:50 - 57:52
    to happen fast
  • 57:52 - 57:53
    there may be times where you want to
  • 57:53 - 57:56
    schedule changing the run level and the
  • 57:56 - 57:58
    the official recommended way to do that
  • 57:58 - 58:00
    is use cron you can set up a cron job to
  • 58:00 - 58:01
    change the run level at a certain time
  • 58:01 - 58:02
    if you want
  • 58:02 - 58:05
    that's one technique you can use there
  • 58:05 - 58:08
    used to be a command called telling
  • 58:08 - 58:10
    and what telonite would do
  • 58:10 - 58:12
    is it would let you set a time delay for
  • 58:12 - 58:14
    when the run level would change and many
  • 58:14 - 58:17
    systems don't have the command anymore
  • 58:17 - 58:19
    and let's see if i do but you have to
  • 58:19 - 58:20
    spell it right if you want to find it i
  • 58:20 - 58:22
    do have it okay so there it is uh
  • 58:22 - 58:24
    telling it it lets you change the system
  • 58:24 - 58:25
    run level so just like the init command
  • 58:25 - 58:27
    but the difference is it takes some
  • 58:27 - 58:29
    options the init command really didn't
  • 58:29 - 58:31
    take any options this one does and one
  • 58:31 - 58:33
    of the options is dash t which is in
  • 58:33 - 58:35
    here somewhere well i didn't see it but
  • 58:35 - 58:37
    it does exist uh where you can come in
  • 58:37 - 58:38
    you can say
  • 58:38 - 58:39
    telling it
  • 58:39 - 58:40
    and then what number you want to go to
  • 58:40 - 58:42
    so i'll say i'm going to run to jump to
  • 58:42 - 58:45
    run level three and you can say dash t
  • 58:45 - 58:47
    followed by a time and you know maybe i
  • 58:47 - 58:49
    want to wait 30 seconds before i do it
  • 58:49 - 58:51
    and so i can specify that i would need
  • 58:51 - 58:53
    to suit it that command
  • 58:53 - 58:55
    and then i'll do that dash t30 and run
  • 58:55 - 58:57
    it okay so that's going to start that
  • 58:57 - 58:59
    timer well notice how mine just totally
  • 58:59 - 59:01
    ignored the timer that's because the
  • 59:01 - 59:04
    telenik command it's an old command it's
  • 59:04 - 59:06
    not supported by most a lot of districts
  • 59:06 - 59:07
    don't even have it and the ones that do
  • 59:07 - 59:09
    don't fully support it so it's kind of
  • 59:09 - 59:11
    the old way so instead if you want to
  • 59:11 - 59:13
    schedule it you're a little better off
  • 59:13 - 59:17
    by jumping in and doing uh a cron job to
  • 59:17 - 59:19
    run in it at a certain time fantastic
  • 59:19 - 59:21
    information managing services with cis v
  • 59:21 - 59:24
    in it great episode as usual thank you
  • 59:24 - 59:25
    don and before we move on i think you
  • 59:25 - 59:26
    have something else you'd like to say
  • 59:26 - 59:28
    yeah you know i've mentioned before that
  • 59:28 - 59:30
    cisvnit is really old and the systemd is
  • 59:30 - 59:32
    really new and shiny and i personally
  • 59:32 - 59:33
    like system d
  • 59:33 - 59:36
    but i think the sysv in it is still
  • 59:36 - 59:38
    really really important you are going to
  • 59:38 - 59:40
    find many many servers that are out
  • 59:40 - 59:42
    there that rely upon it and if you start
  • 59:42 - 59:44
    jumping into other operating systems
  • 59:44 - 59:47
    like freebsd and open bsd and those guys
  • 59:47 - 59:49
    they still use cisv in it too systemd
  • 59:49 - 59:51
    hasn't made the leap over those sides
  • 59:51 - 59:54
    yet so learning how this works is a
  • 59:54 - 59:55
    skill that you'll be able to apply many
  • 59:55 - 59:57
    different places definitely definitely a
  • 59:57 - 59:58
    valuable one to have great advice thank
  • 59:58 - 60:02
    you don here's some more great
Title:
CompTIA Linux+: Managing Services #11
Video Language:
English
Duration:
01:00:01

English subtitles

Revisions Compare revisions