00:00:00 - Okay, welcome to Section 101.3 about runlevels
00:00:05 - and rebooting. What we're going to talk about in this nugget, we're going to talk
00:00:08 - about when the computer boots up, there are several different
00:00:11 - runlevels. So we're going to go through the runlevels,
00:00:15 - inittab which is, determines what runlevel a computer runs
00:00:19 - at, and then startup processes which take place in the
00:00:22 - init.d folder, how to switch between runlevels, and then
00:00:27 - rebooting and shutting down some of the ways that we have to,
00:00:31 - that we have to do that, also some messages that we can send
00:00:34 - to people. And then I want to briefly touch on upstart which
00:00:38 - is basically replacing a whole bunch of the stuff that we need
00:00:41 - to learn for the LPIC certification. So let's get started.
00:00:46 - We're going to start talking about what runlevels actually
00:00:49 - are. Alright, so a good way to think about runlevels is to think
00:00:54 - about them as like modes that the Linux computer runs in. Now,
00:00:57 - some of these are extremely standardized. For example, the
00:01:01 - runlevel 0, again these are computers so zero is a number,
00:01:05 - runlevel 0 is the halt level, meaning the, the stop or,
00:01:10 - or, you know, just halt the system. And this is one of
00:01:13 - the ones that is standard across all Linux distributions.
00:01:17 - The next runlevel is runlevel 1. Now, this is called single
00:01:21 - user mode. Some of the, sometimes distributions like currently
00:01:24 - Ubuntu, for example, calls this recovery mode, and the reason
00:01:28 - it's called recovery mode is because
00:01:31 - this is where you don't usually need any password to log in
00:01:35 - as the root user. So if your system is completely messed up
00:01:39 - and you have physical access to the machine, you can get into runlevel 1.
00:01:42 - Again, we're going to see how to do that in a little
00:01:45 - bit. This is another one of those runlevels, runlevel 1,
00:01:48 - single user mode or recovery mode is standard across all
00:01:51 - distributions. So it's important to know that. Then we get into
00:01:54 - some that aren't standard. Now, 1 or 0 through 6 are the
00:01:58 - runlevels that are available to Linux systems. But different
00:02:01 - distributions use some of them differently. For example, runlevel 2
00:02:04 - in a Debian-based distribution like Ubuntu,
00:02:09 - this is the default runlevel. This is the runlevel that everything
00:02:12 - runs in whether you're running X Windows or just running in
00:02:15 - the terminal mode, everything runs in runlevel 2. So this is
00:02:18 - like a Debian-based operating system's normal mode or default
00:02:23 - mode. So that's, again, if you're using a Debian or Ubuntu system.
00:02:27 - Now, runlevel 3, if you have a Red Hat system or a SUSE Linux
00:02:31 - system, this is a runlevel that they use for text mode. So
00:02:37 - if you want the computer to fully boot up and be usable but
00:02:39 - you don't want to load a graphical user environment or X Windows,
00:02:43 - that's where runlevel 3 comes. So like a lot of
00:02:47 - servers, Red Hat servers or SUSE servers, are running at runlevel 3
00:02:51 - because they don't use a graphical user environment.
00:02:54 - Runlevel 4, again, this is available and you can customize
00:02:57 - this if you want, any of them, apart from 0, 1 and we're going
00:03:00 - to talk about 6 later on. But 1 through 5 are customizable.
00:03:04 - This is just the default, but 4, 4 is kind of special because you
00:03:08 - can make your own runlevel. If, if there's something you specifically
00:03:11 - want, say, you want certain programs to load, you want certain
00:03:15 - services to load in a certain configuration, you can customize
00:03:19 - runlevel 4 and you can call it whatever you want, wild card.
00:03:22 - It's, it's not one that's used by default in any major distributions.
00:03:27 - Then we have runlevel 5 which, again, this is just a
00:03:30 - Red Hat SUSE thing. This is their GUI mode. So if you have Red Hat
00:03:34 - or SUSE, generally your, your computer usually runs
00:03:37 - in either runlevel 3 or runlevel 5. Runlevel 5 is
00:03:41 - the one that loads X Windows. Generally, runlevel 5
00:03:44 - will have a graphical login screen. We're going to you see that in a
00:03:47 - minute. So that's the, that's how they default to a GUI mode
00:03:52 - using runlevel 5. And then last but not least, this
00:03:55 - is another special one, runlevel 6, which is the reboot
00:03:59 - runlevel, which if you reboot your system, it goes into
00:04:02 - runlevel 6, and that's what happens, it reboots. So again,
00:04:06 - these are the runlevels defined. This is where they're normally
00:04:09 - used. And again now, if it's a little confusing, Debian and
00:04:13 - Ubuntu only using runlevel 2, what they do is they
00:04:17 - allow you the option in runlevel 2 to start the graphical
00:04:20 - user interface or not. They just didn't make it a whole new
00:04:23 - runlevel. So it's, it's key to know that Red Hat and SUSE
00:04:28 - use runlevel 3 or 5, Debian and Ubuntu, those
00:04:31 - types of distributions generally just use number 2, but
00:04:35 - 0, 1, and 6 are all pre-defined. These are Linux standard
00:04:39 - runlevels for halt single user mode and the reboot mode, alright.
00:04:44 - So let's move on and, and look at some of the, how this
00:04:48 - works in an actual running system.
00:04:52 - Okay, you can see that I've booted up my system here. Now, this is running
00:04:55 - CentOS which is basically Red Hat, CentOs version 5.4.
00:04:59 - And since it booted up and gave me this text-based login
00:05:03 - screen, you can safely assume that it's probably set at runlevel 3.
00:05:08 - Let's check that out right now.
00:05:11 - The login is root and where the default runlevel information is stored
00:05:16 - is in the etc directory and the file, vi is the editor that
00:05:20 - I am going to choose to use here, but it's in a file called
00:05:23 - inittab.
00:05:25 - So let's look inside here. Now, oh, you know what, this is actually
00:05:28 - just what I described to you in the last, in a couple slides
00:05:31 - ago. Maybe I should have just brought you in here instead of written
00:05:34 - all that out. But anyway, that describes the runlevels in a
00:05:38 - Red Hat system. So
00:05:41 - you'll notice here it says, multiuser mode, without NFS.
00:05:45 - So Red Hat uses runlevel 2 as a multiuser system
00:05:52 - but without loading NFS, and that's the way that they've
00:05:55 - chosen to use runlevel 2. What this shows right here,
00:05:59 - the initdefault, it shows the init runlevel is at 3
00:06:04 - which is what we guessed. So we can pat ourselves in the back because
00:06:07 - we guessed correctly. This text-based login means that we're at
00:06:10 - runlevel 3. Now, this file shows a bunch of other things
00:06:14 - as well. For example, it talks about what to do when it
00:06:17 - boots up into certain runlevels to go to that
00:06:22 - rc.d directory and run the, the
00:06:24 - boot up files. We're going to talk about that in a minute. It says,
00:06:27 - here it, it says what to do if you do ctrlaltdel.
00:06:31 - Now, what it actually does on the system if you type ctrlaltdel,
00:06:33 - it runs the sbin/shutdown command
00:06:38 - with these flags. Now, pay attention to this because we're going
00:06:41 - to look at how to shut down and reboot systems in just a little
00:06:44 - bit. But anyway, that's something to look at. And then down here,
00:06:48 - the same kind of thing. This is actually neat. If there's a UPS
00:06:51 - that sends a signal to the, to the computer that it's lost power,
00:06:55 - of course a UPS will keep it running, but this is going to
00:06:58 - do something that's going to say, power failure, system shutting
00:07:00 - down and it's going to do that in two minutes. So it's going to
00:07:04 - give a two-minute warning to the people logged in. Again, that warning
00:07:08 - is something you really need to know how to give for
00:07:11 - the LPIC certification. Now, this is neat too. You can shut,
00:07:14 - you, you can cancel a shutdown process. Say, the power kicks
00:07:17 - back on, then if you do the shutdown -c with this, it will
00:07:20 - actually stop that shutdown process. So like if you're a Star Trek
00:07:24 - fan and the auto-destruct sequence has started, you can stop the auto-shutdown
00:07:28 - sequence after it's already begun even if you're not Captain
00:07:32 - Picard. Anyway, this starts up the login screens like we, we logged in,
00:07:37 - you know, you saw that login prompt and password prompt at first. Those are programs
00:07:41 - that have to run. And then we mentioned runlevel 5 is a
00:07:45 - GUI environment. So this runs xdm which is the X display
00:07:50 - manager only during runlevel 5. So it's saying if it's
00:07:54 - runlevel 5, then you want to run this preferred desktop manager.
00:07:58 - Now, again, if you're, if you're an X Windows geek here, xdm
00:08:02 - is very rarely used the program itself, but an X display
00:08:06 - manager, either GDM or KDM for Gnome or KDE is generally what
00:08:11 - it's gonna start, and this preferred desktop manager program is
00:08:14 - going to read your configuration files and determine what graphical
00:08:18 - user login to start. But that's a little bit beyond the scope
00:08:22 - of this. Basically, the inittab shows the init process how
00:08:27 - to start. And remember the init process, that's the very first process
00:08:30 - that boots or that, that runs on a system and spawns everything
00:08:33 - else. So this is kind of like the configuration file for init.
00:08:36 - And now what we're going to do is look at what, how init
00:08:41 - starts these things like, here, let me scroll back up here. See all
00:08:44 - these etc/rc.d folders? These are folders that
00:08:49 - are talking, that are referencing startup scripts, and we're
00:08:53 - going to look at that next. But let's look over what we just
00:08:55 - talked about in inittab so you kind of get exactly what it
00:08:59 - is. It is just a configuration file.
00:09:03 - Okay, so init, it tell, or inittab, this file, tells init what to
00:09:07 - do. It sets the default runlevel and it's required knowledge for
00:09:12 - LPIC. And I wanted to bring this slide up just to focus on the
00:09:14 - inittab a little bit more. It's required that you understand
00:09:17 - and can configure inittab file, but the whole idea of
00:09:21 - that is being phased out or phased out with the upstart program
00:09:26 - and that could, way to configure stuff. Right now the upstart program
00:09:28 - which is in Ubuntu, it does, it's backwards compatible. So if
00:09:33 - you put things in a file called etc/inittab,
00:09:36 - it will honor them. But even that eventually will most likely
00:09:39 - go away. You still need to understand this because right now in Red Hat,
00:09:42 - in the Red Hat Enterprise Linux and, and those types
00:09:46 - of things, it, it's still, that's the way you configure
00:09:49 - things. But if you have, for example, on your computer Ubuntu
00:09:52 - installed then you say, oh, I'm going to check out my inittab file, it actually
00:09:56 - won't be there. There's no inittab file at all, but you still need to
00:09:59 - understand and, and know how to use it, alright. So what does inittab
00:10:03 - do? It, it tells init what to do next, alright. It's the configuration file.
00:10:06 - So let's look at some of those ways that you can configure
00:10:09 - startup scripts, alright.
00:10:14 - Okay, inside the et cetera directory again or etc, this is where most
00:10:18 - of our configuration things are, there's a folder called
00:10:21 - init.d.
00:10:23 - And inside here you're going to see all of these different files.
00:10:27 - Now, these are scripts like command line scripts that were put
00:10:31 - here by different applications. Now, you can add some yourself,
00:10:33 - but these are mainly just scripts. Well, I'll look at one really
00:10:36 - quick.
00:10:38 - For example, if we look at the NFS script, okay, it's this
00:10:43 - long script that does a whole bunch of stuff, okay.
00:10:46 - This is the, it starts up the NFS, the network file sharing
00:10:50 - server. So all of these are programs like that that start
00:10:53 - things or also stop things. For example, if you want to
00:10:56 - stop something, you use these programs too. It's just kind of like the,
00:10:59 - the switch to turn things on and off. For example, let's shut
00:11:03 - something off. Let's do, let's, something that's not going to hurt us
00:11:06 - here. I hate for it to just shut off something that's going to hurt. So we're going to
00:11:10 - do sendmail, okay, sendmail.
00:11:14 - We're going to send it the stop command. Now, I did the dot
00:11:17 - and then forward slash to say that it's in this directory. We're going to talk
00:11:20 - about path and stuff later, but just know that if
00:11:23 - in a file like this you're going to have to do./sendmail
00:11:25 - to say the files right in here. Let me say stop and then it's
00:11:29 - going to stop the sendmail process. That told us what it was doing.
00:11:33 - If we want to start it,
00:11:35 - sendmail start.
00:11:37 - And most of them have commands like this.
00:11:41 - If we just say that, I will give us our different options. So we could
00:11:44 - restart. We can do a conditional restart. Just get the status so sendmail status.
00:11:49 - Oh, good. It's running. It tells us it's running. So this is where
00:11:52 - all the commands for different server processes live, okay. This is how you start up
00:11:56 - and stop things. But you'll notice that these aren't, these aren't
00:12:00 - separated by runlevels, okay. Now, the different runlevels,
00:12:03 - let's look back here and what I'm going to do is ls -l, and I'm just
00:12:09 - going to look for rc., grep for rc., just so that
00:12:14 - that's all we see. Alright, so what we have here, you'll see that
00:12:19 - there's these files. There's rc, there's rc0, rc1, rc2
00:12:23 - and these probably are going to look a little bit familiar, right?
00:12:26 - Now, the rc, the number, and then the.d means
00:12:30 - the different commands at that runlevel. Now, there's also
00:12:34 - rc.local which runs at every runlevel and
00:12:38 - like rc.sysinit. And these, these are things that run
00:12:41 - no matter what. But we're talking about the different runlevels
00:12:44 - have different options and different, different things that start up.
00:12:46 - So let's look into, let's see, we're running in runlevel 3,
00:12:49 - right? So let's go into the rc3.d folder.
00:12:54 - And now, if you're expecting to see a bunch of different scripts,
00:12:56 - well, they look a little bit funny. First of all, they're blue.
00:12:59 - Well, why are they blue? Well, let's look at it, ls -l.
00:13:02 - We'll see that these are symbolic links and it points
00:13:06 - to.., previous directory, init.d, that folder we
00:13:10 - we're in last time, and then one of those files. See how it shows
00:13:13 - one of those files that we're looking at before? And you'll
00:13:17 - notice that they're not named exactly the same either. They
00:13:20 - start with either a k or an s, a capital K or a capital S, and then
00:13:24 - a number and then the name of that, that startup and shutdown
00:13:29 - script. So why, what's with the K's and the S's? Well, it's not
00:13:32 - too difficult to understand it. The K means you kill the process
00:13:36 - or shut it down and the S means you start it up.
00:13:40 - You may be thinking, okay, if I boot into runlevel 3, why would
00:13:43 - I be killing off processes like, like NFS, right? NFS
00:13:47 - isn't, isn't going to be running. Why would I, why would I need to shut that off?
00:13:50 - Well, the reason is we can switch between runlevels while
00:13:55 - the computer is running. So you may want to kill a bunch of processes
00:13:59 - and start up a bunch of different ones. So every runlevel
00:14:02 - has these things that it stops and these things that it starts
00:14:05 - and they're going to be a little bit different in every
00:14:08 - runlevel. So let's look, cd../rc4.d.
00:14:15 - Okay, there's a bunch of stuff in here, but it's a slightly
00:14:19 - different list, alright. You'll see, for example, there's no, oh, I'm trying
00:14:24 - to look at one that's not here. Okay, up in the top you saw there's
00:14:27 - that first boot, S99, first boot, and there's not that one
00:14:33 - in this rc4.d, right? So first boot is a process
00:14:37 - that they don't start. Well, that's interesting. A lot of
00:14:42 - these processes are going to be similar across different runlevels
00:14:45 - because you're going to want all of them to be working like networking,
00:14:49 - you want networking to work in pretty much every runlevel
00:14:52 - except like that runlevel 1, that single user mode, that's
00:14:55 - not going have, let's look, here. Let's go back there and look.
00:14:58 - runlevel. So let's look, cd../rc4.d.
00:15:02 - Let's look. See here, almost every single process is killed. See, because
00:15:07 - it has that K under it. So the only thing that started is
00:15:11 - the vm2 monitor which is
00:15:14 - a virtual machine or,
00:15:16 - let's look and see what that is,
00:15:19 - vi S02 l.
00:15:22 - Alright, so this one is,
00:15:26 - oh, the event manager. Yes, so the kernel event manager runs.
00:15:29 - That makes sense. Even in single user mode, we're going to want
00:15:32 - that, but everything else is mostly stopped, okay, because we're
00:15:37 - in just recovery mode. If something is going wrong, we don't
00:15:40 - want all those different processes to be running. So that's
00:15:43 - how these different things work. Now, you can manually create
00:15:46 - things, for example, oh, if we're going to totally mess up our
00:15:49 - system, we're going to do a symbolic link to
00:15:54 - ../init.d/nfs and we're going to link it
00:16:00 - to start, okay, and we're going to do it in what order?
00:16:06 - 88 just because, nfs, okay. So now, what does that done? Let's do an ls.
00:16:11 - And now we see, right over there you'll see S88nfs
00:16:16 - at the, almost to the very end. So it is going to
00:16:19 - start nfs in single user mode. Now, the network isn't running
00:16:22 - so it's going to hang and it's not going to work. It's not something
00:16:25 - I would suggest doing, but that's how you would do it, alright.
00:16:28 - And you'll notice the, the things are all in numerical order. Well, that's
00:16:31 - because that's the order it does things in. You know, some things
00:16:34 - like nfs, for example, you want nfs to start after networking
00:16:38 - starts. So you would put the number of nfs higher than the number
00:16:42 - for networking. So networking starts before. Does it make sense?
00:16:45 - The same thing going backwards. If you're going to kill a process,
00:16:49 - that depends on networking, you want to stop the process before
00:16:52 - you stop networking because, obviously, if you stop networking
00:16:56 - first, it's going to complain. For example, if you look up,
00:17:00 - here I'll show you, if you look right up here, kill 90 network,
00:17:05 - see, that happened towards the end of the killing process as
00:17:09 - you see. It stopped all these things that depend on networking. All
00:17:12 - of these processes, most of them depending on networking,
00:17:15 - stopped before networking because if you just kill networking,
00:17:18 - well, all these are going to hang and bad things are going to happen.
00:17:21 - So you have to know that there's two things. There's the K or the S
00:17:24 - for kill or start, and then there's a numerical order it processes
00:17:28 - all of these different scripts. Now, I don't want to have my
00:17:32 - system completely messed up. So I am going to
00:17:36 - erase that nfs thing that I just entered there. Yes, I want to remove that symbolic link.
00:17:39 - But again, these aren't actual files. These are just links back
00:17:43 - to that init.d folder where all those scripts are. And
00:17:46 - if it's a K in the beginning, it stops it. And if it's an S at the
00:17:49 - beginning, it starts it. So now you are a pro on the
00:17:54 - rc number.d folders, alright. So let's look at what we've
00:17:59 - learned so far, and we'll move on to rebooting the system and notifying
00:18:03 - users because that will be terribly, terribly important if
00:18:07 - you are going to do some maintenance on your server.
00:18:10 - Okay, so init.d, these are the startup,
00:18:15 - startup and shutdown.
00:18:22 - These are the scripts that run, okay, and that's where they're stored.
00:18:24 - Now, usually, packages will put things in your, you don't have to write
00:18:27 - these scripts or even place them. But these are where they're
00:18:30 - located. And then down here, etc/rc and then
00:18:34 - this is the number. I just put that X there to,
00:18:38 - to show whatever runlevel folder you're talking about.
00:18:40 - So rc, the number for other runlevel that you're currently
00:18:43 - at or switching to,.d, and inside are symbolic links,
00:18:48 - but you got to spell symbolic right,
00:18:52 - symbol,
00:18:57 - We'll pretend that I spelled that right right at the beginning. I didn't
00:19:00 - have to pause the thing and spell it out. Put symbolic links back
00:19:05 - to these. So again, these are symbolic links to this folder,
00:19:11 - the scripts that live inside that folder. The K at the beginning
00:19:16 - is whether it's killed or started or kill or start,
00:19:22 - the number, usually a two-digit number,
00:19:29 - and then the actual name
00:19:34 - of the script. So we have K01 name of the script, S01
00:19:40 - name the script and it's either kill or start the process depending
00:19:45 - on what you want it to do. And now what we're going to do is
00:19:50 - talk about switching in between. Now, again, when you switch
00:19:53 - between runlevels, that's where the kill and the start things
00:19:57 - really matter, okay, because again when you just boot a system
00:20:00 - into the default runlevel, there's not going to be any programs
00:20:03 - that are there for it to kill off, right, because it's just starting.
00:20:07 - But when you switch between runlevels, it's going to kill
00:20:10 - off the processes that shouldn't be running in the runlevel
00:20:12 - you're switching to. So that's where the, the K and S really
00:20:16 - matter or really make the most sense is when you're switching
00:20:18 - between runlevels and not just starting up, okay. And I still
00:20:21 - spelled symbolic wrong. Can you believe that? Symbolic links. Boy, I'm having a rough time
00:20:26 - today. Anyway, symbolic links are the named these, pointing back
00:20:32 - to the scripts that reside inside init.d, alright. So let's
00:20:36 - look at how to start up and shut down the computer properly
00:20:40 - with notifying people because that's one of the keys in the
00:20:43 - LPIC certification. You need to know not only how to restart
00:20:47 - and shut down, but you need to know how to notify users, how you're,
00:20:50 - how you're going to do that, alright.
00:20:53 - Okay, we're back here at the command line. What I want to do
00:20:55 - is look at the manual page for the shutdown command, alright.
00:20:59 - Inside here you're going to see that shutdown actually does
00:21:02 - quite a few things, alright. One of the nice things it will
00:21:05 - let you do is it will let you just warn about it and not
00:21:09 - actually do it. For example, this
00:21:11 - -k, it's not really shut down. It just sends a warning
00:21:15 - user to everybody. So if you're planning on shutting down in the
00:21:17 - future but you don't know what time, you just want to send a warning
00:21:20 - out to people, you can do that. You can have it reboot instead
00:21:22 - of just shutting down which is great if you're not near the
00:21:25 - server because if it's just shutdown, you have to go press the power button. That
00:21:28 - can be a real pain in the butt. If you can do some other
00:21:33 - things like, here, let's scroll down a little bit more. There's some other
00:21:37 - things here. You can cancel an already running shutdown. We learned
00:21:40 - about that in the inittab file. Remember, if the power comes back
00:21:43 - on, we can tell it, okay, I don't really want to shut down. Never mind.
00:21:47 - But the one thing is the time. You have to tell it when to shut
00:21:50 - down and that accepts a couple different types of inputs.
00:21:55 - It can be a specific time like 12:05 we're going
00:22:00 - to do it or it can be like how many minutes from now or you
00:22:04 - can actually use the word now if you want which stands for
00:22:07 - +0 minutes, meaning in zero minutes or right now
00:22:10 - I want you to shut down. So let's look at a, at a few examples of
00:22:13 - what that looks like in action, okay. Let's clear this. We're going to do
00:22:17 - shutdown -k. We're going to do it, let's say, now, alright.
00:22:23 - Again, k doesn't really shut down, but we're going to send
00:22:27 - this message,
00:22:29 - oh, my goodness, there's a monster, okay.
00:22:35 - So everybody got this message that says, oh, my goodness,
00:22:38 - there's a monster. The system is going to shut down to maintenance
00:22:41 - mode now. But of course, since we said -k, it was canceled, right?
00:22:45 - So alright, let's do it, instead of now, let's send a different message.
00:22:48 - Let's say, shut down, we're not going do -k. We're going
00:22:54 - to do, well, let's say, +3 minutes, alright. So it's going
00:23:00 - to shut down in three minutes, and we're going to send the message,
00:23:03 - I have to install Halo. I just got the CD, alright.
00:23:12 - So everybody that's logged in on the terminal, this will pop up.
00:23:16 - So this broadcast message isn't just for me, right? It's not
00:23:19 - just for me. It's everybody got that message.
00:23:23 - Shutdown was canceled, alright. So what if we wanted to let
00:23:28 - that run in the background so in that three minutes I could do a couple
00:23:31 - really, really cool things? You know, for example, let's just
00:23:34 - hold on to my command prompt, I had to hit Control-C and then it canceled
00:23:39 - the shutdown. So let's say we want to do that. We'll add the
00:23:42 - ampersand because the ampersand will put it in the background, alright.
00:23:45 - Let's look at that message. It will still be running, but I'll have
00:23:48 - my command prompt back, alright. So see there? Now, I have my command
00:23:52 - prompt, but it just said, in three minutes it's going to shut down and you
00:23:56 - better believe in three minutes this computer is going to shut down. But
00:23:59 - then I discover, oh, you know what,
00:24:02 - I don't want to shut down to install Halo.
00:24:04 - shutdown -c for cancel and then we'll tell people why
00:24:08 - we're canceling too. We're going to say, it turns out Halo doesn't
00:24:13 - run under Linux.
00:24:19 - Shutdown canceled. So everybody got this broadcast message
00:24:22 - that it turns out Halo doesn't run under Linux. Shutdown canceled, alright.
00:24:26 - And then the shell told us that that shutdown +3, it's
00:24:31 - done, it finished, alright. So that's how you can warn everybody
00:24:34 - of an imminent shutdown and that's how you can actually shut down
00:24:38 - the system. Now, we have one more thing that we need to learn
00:24:41 - before we move on to the next nugget, and that is about
00:24:46 - init and telinit. Now, we're talking about switching between runlevels.
00:24:49 - Well, right now we're in runlevel 3 because that's the
00:24:52 - default that we've booted into. But if we want to change, we can do one
00:24:56 - of two things. We can tell the init command. Now, remember, init
00:25:00 - is the process that runs every other command, right. So we can
00:25:03 - tell init to go into runlevel, let's say runlevel 1.
00:25:09 - Well, we can tell it to do that. That's not really the proper
00:25:12 - way to do it. The best way to do it is use a command called
00:25:16 - telinit
00:25:18 - and then the runlevel you want it to switch to. So we do that
00:25:21 - and it's going to switch to runlevel 1. You see how it's stopping
00:25:24 - all those processes. Now, if you remember, a few minutes ago, you
00:25:28 - can guess all of those processes that it's stopping were the
00:25:31 - ones that had the K in front of it. And then it starts up,
00:25:36 - let's see, okay, and then it started up like one, yeah, going into single user
00:25:40 - mode. It didn't do much because, remember, a single user mode
00:25:43 - had barely anything running. And thankfully, I erased that NFS
00:25:47 - command that put in there because otherwise it would be hanging
00:25:49 - saying, I don't have any network connection. So right now we are
00:25:52 - in user or single user mode in runlevel 1, and let's say we
00:25:57 - want to switch back to runlevel 3. Again, remember I said init
00:26:01 - or telinit is you can do that, and we're going to see in Linux that init works
00:26:06 - the same way as if I were to type telinit, alright. Now, it's
00:26:10 - taking a little bit longer because it has to do more stuff to
00:26:13 - switch into mode or level 3 because there's all these
00:26:17 - things to start up. Now, it's going to start all those things up.
00:26:21 - And then I want to show you the difference. See, now one of the
00:26:23 - things it started up was that login command. Remember, runlevel 1
00:26:26 - doesn't have a login. It just logs you right in as the root user.
00:26:30 - So if you forget your root password, you want to go into single user
00:26:33 - mode so you can fix that. But we have to log back in, alright.
00:26:38 - And now what I want to show you, ls -l /sbin,
00:26:43 - this is the directory that init is stored in. I want
00:26:47 - to grep init. So it just shows us the things with the word
00:26:50 - init in it. Now, if you see the one on the bottom there, the telinit
00:26:53 - command is just a symbolic link pointing to the init command.
00:26:57 - So really in this Linux system it doesn't matter if you use
00:27:01 - telinit in the runlevel or init in the runlevel.
00:27:04 - But the, the proper or the, the more correct way to do it, the preferred
00:27:10 - way to do it is to use telinit because there are some systems
00:27:13 - like Unix that won't work if you telinit directly
00:27:18 - to switch runlevels. It just doesn't accept user commands
00:27:21 - from even root. So telinit will be a different program
00:27:25 - on those systems that tell init what to do. So while, while
00:27:29 - running init and then the runlevel will work in a Linux system
00:27:32 - perfectly fine because it's just a symbolic link. Telinit
00:27:35 - is just a symbolic link to the init command. The proper way to do
00:27:39 - it is to use the telinit command so that no matter what
00:27:42 - kind of a Unix or Linux system you're on, you can, you know,
00:27:45 - you can be assured that it's going to work. So that's the difference
00:27:48 - between telinit and init, and right now you know more than
00:27:51 - probably 50% of the Linux admins out there. Nobody really, most
00:27:55 - people don't know why you use telinit or init. They just know that
00:27:57 - it's proper to use telinit. And now you know more than a lot of people.
00:28:01 - So anyway, that is basically all we have to learn about in
00:28:05 - this section. So let's look back over, make sure we cover anything,
00:28:08 - and then we can move on to the next section or the next nugget
00:28:12 - that we're going to go over.
00:28:14 - Alright, it looks like we did a good job here. We covered runlevels
00:28:19 - very thoroughly. We went over inittab and some of the things
00:28:22 - that you can edit in there, basically that it's the configuration
00:28:25 - file for the init process to say what to do when it boots
00:28:28 - up. We went over the init.d folder which contains all the
00:28:32 - scripts to start and stop the different services that are running
00:28:35 - on your Linux box. We learned not only how to use init and telinit
00:28:39 - but actually what the difference is between them and just
00:28:42 - know that telinit is the one that you want to use because that's
00:28:44 - the more proper way to do things. We learned how to reboot
00:28:48 - and shut down, and specifically with shutdown we learned how to
00:28:52 - send some broadcast messages. Now, one of the things that you may
00:28:56 - be wondering is what if people are logged in to the graphical
00:28:59 - user environment? Well, generally, there's only one user and
00:29:02 - a computer if they're logged in to the graphically user environment.
00:29:05 - So you don't have to worry too much because it's generally
00:29:08 - you, and if you're going to reboot your computer, you know it.
00:29:10 - But a lot of times on a server many people will be logged
00:29:14 - in in the console, you know, over the,
00:29:16 - over the text-based thing. So you want to be able to send that message
00:29:19 - to all the users saying, hey, save your stuff or, you know, just know
00:29:22 - it's going to reboot. So that's why it's important for us to know how to send those
00:29:25 - command line messages. And then we briefly talked about and
00:29:29 - briefly because really that's, it's not something you're going
00:29:31 - to be tested on at all but upstart is a new configuration system
00:29:35 - that's kind of going to replace inittab and that whole init
00:29:39 - process that it is now. But what we learned today about inittab
00:29:42 - is what you need to know for the test. Just don't be confused if
00:29:45 - some of those files are missing in the systems that you administer
00:29:49 - on a day-to-day basis, alright. So I hope that this has been informative
00:29:52 - for you, and I would like to thank you for viewing.