I'm sure you've noticed when you boot up Fedora, you don't get an option to select
anything else you get no menu. It boots you straight
into the operating system into to log-in screen. we'll talk about
how we can change that. I like to have a little bit more
control than what Fedora gives us. First thing is we've got to get into a
terminal session so open terminal and then I need to get over to the
root user Okay, so you see the pound sign that indicates that it is the root user plus you see route over here. And again, I'm in the home directory of the root
user now I want to change to the location of the GRUB Boot Loader. Let's take a look at
what's there and you'll see that there is the
grub.comp file that's one of the files that can be
modified to change the grub configuration. Another file is called menu.lst. That's what you that is what is used by Suse.
Notice that the colors are a little bit different in this one. This one is a blue and splash is a red. The colors indicate that the file is different in some way the red indicates that its a compress file like a zip file or a tar file. The blue indicates that it's a link. We haven't studied links yet but you'll understand that later.
So let's look at it in a little bit different way with the dash-l. So again you can see that the colors still are true. The blue and the red but now notice there's a little arrow that points over to the current directory with the dot foward slash grub.conf and all the way over here with the permissions, this area, you notice that it starts with a "l" meaning that is a link. So we're going to go in and modify the grub.conf file and we're going to use a text editor that you haven't been introduced to yet but you will learn more detail on this.
Probably more than you want to know in a later chapter. It's called vi So we're going to type vi space grub.conf. Notice there's a lot of lines up here that start with a pound sign. that pound sign indicates that it's a comment. Anything that you start with a pound sign, the system will ignore it, because it considers it a comment. So let's take a look at a few these things. Remember the default meant which item in the list it was going to select and remember in computer language zero is the first one instead of number one. Then we've got the timeout is set for zero. That means that it's not gonna pause at all.
It's just going to automatically go into the operating system. Then we've got the splash image and that tells us what the actual image is that is going to be displayed after the boot-up finishes. Then note hiddenmenu - by default that's enabled so we're going to have to comment that out in order to be able to see the menu. Then we see the term 'title' it's a fedora in here is all the information on it. Route... Where's the route drive? It's on the first hard drive on first partition. Then it gives the kernel information that this operating system is going to be using. Noticed the initrd that's the one that creates the RAM disk and loads a small version of Linux.
Now you've seen a little bit about it let's make some changes to it. In order to make a change in this, I have to type the letter i. Notice -- INSERT -- pops at the bottom that means I'm now in edit mode. I can insert, delete, change whatever. Anything that I need to. So I'm going to come up here to hidden. I'm just trying to use my mouse.. which doesn't work. All you have in the vi command is your keyboard. This has been around for much longer than what the mouse has been here.
Take a little bit time getting used to on this one. Okay, so now we've commented out the hidden menu so that means the menu will show up when you first boot your system but it's going just flashed across the screen because at this point we've got the time out set to 0. So I'm going to come over to the zero and then I'm going to change that to 10.
That means is going to wait 10 seconds before it automatically picks the default setting which is up here on this line. So at this point we have now changed to where we can see the menu it will wait 10 seconds before it picks the default operating system and in this case right now there's only one, the Fedora. So when the menu shows up that's all we would see So let's add another one. Here we're going to add another title. Let's call it floppy disk that way you could create a floppy disk to boot from and you would have the option to pick that option from the menu Now we have to put the route information so we tap route and in this case we're going to use a little bit different command and it's called routenoverify and then we're going to put the drive that it is on and since you don't partition, floppy drives there's no partition number.
Okay, with that routenoverify means is the system doesn't have to recognize the OS for it to boot from it. You would use this like if you're going to boot a Windows system, for instance. Then we go to the chainloader and we put plus one; which means that it's going to read one sector from the start of the partition that allows it to boot from the floppy. Okay, so we have changed the hidden menu.
We've commented that out so now we'll see the menu. We've changed the time out to 10 so before the default selection is made then we have a chance to change something. We've also added the option of booting from a floppy disk. To get out of the insert mode, you hit Esc, Then a colon to get to the command-line tool and type exit. That is how you get in and out of vi. That is very quick little tutorial on it. Now in order to reboot, we can do this using the init 6 command. And you will learn a little bit more about that in a future lesson too. So init 6 is the same thing as doing a reboot. Now notice 7s, 6s, 5s ... I'm gonna hit one of my arrow keys left or right I could have actually hit any key on the keyboard and it would have stopped the countdown. So now we are at the GRUB menu option. So we have a choice of either of booting into Fedora or to the floppy disk. Notice Fedora is your first on the list so that's what the default boot is going to be.
Notice the text underneath the box; Use the up or down arrows to select which entry is highlighted. Press enter to boot to the selected OS. You can use the letter e to edit commands before you boot, you could press a to modify kernel arguments before booting, or c to go into a command-line. Let's talk a little bit about the a command to modify the kernel arguments. One of the things that will cover shortly is the run level so if you wanted to you could change the run level. I'm going to press the a key and it takes you to a prompt that allows you to make modifications to the the kernel.
If I wanted to change to say, run level 3, I would just happen number 3 at the end of that line and hit enter, but I don't want to make that change. Let's select the Fedora and boot into it. Now that our system has booted, we will sign in and we're going to add a little bit more to our grub.conf file. If you want to password-protect this file, you'll need to modify it again and add a couple more commands. So let's get logged in first and then we'll go to a command prompt and then we'll go to a terminal session. First thing that we need to do is open a terminal session. I like to use the terminal session rather than console because it gives me a nice white background and I also have some options and pull down menus. So the first thing that we have to do is login as the root user. Again, remember we know that we're in as root, because we have the pound sign (#). Now we're going to use a different text editor to make further modifications.
This editor is called gedit and rather than changing to the directory, we're just going to go ahead and type it all out. I'm going to use an ampersand (&) to indicate that I want it to run in the background so that I can continue to use my shell prompt. I hit enter and it brings up my gedit application. You can see from here that the changes that we made earlier are still there, they were saved.
Notice we've got our floppy disk information now. So now let's consider putting a password on this. It would be much safer if we could protect it to where only a certain number of people would have this password in order to get into the grub.conf and make any changes. Let's come up here, and type the word 'password'. Now of course I could continue and put a password in there, but if I did that it's going to be sitting in cleartext, and if anybody got their hands on the grub.conf file, then they would have the password.
So let's encrypt it. We're going to go back to the terminal window. We're going to use a command to encrypt the password. (grub-md5-crypt) Now er enter the new password, and retype it. That password has been encrypted. That big long line of characters is the encrypted password. So what I'm going to do is highlight that and I'm going to 'edit' and 'copy' then I'm going to go back to the gedit and I'm going to go behind the word password that we just used and I'm going to put dash dash md5 (--md5) and then I'm going to paste that long stream or the encrypted password in there.
So now we've established that we're using an encrypted password and that there is one, but at this point we haven't really applied it anywhere. We come down to right before root and put lock. So before anything happens, when we select Fedora, it will automatically ask you for a password. Let's do the same thing on the floppy disk. Now we have set a password and we've told it where we want the screen to get locked and request a password.
So from here we save our file, close the gedit. Now in order for this to take affect, we have to reboot the system again. So we're in a type the 'init 6' again to force a reboot. And then again will wait until it restarts. Now we have our system booted up. You notice that the text underneath the box has changed a little bit. You can use the arrows again to move around but you have to use the 'p' in order to enter a password and have it unlock it.
So now we typed the password, notice again it's not in clear text. Now it takes you back to the original menu that you saw last time with the 'e', the 'a', and the 'c.' - e for edit the commands before booting, 'a' for modifying the kernel arguments or 'c' for going into a command-line. So at this point, let's hit the 'e' and see what happens. It brings up the portion that was under the title Fedora. You've got your lock, you've got route, the kernel information, and the init.rd image that you're going to use. You can modify anything on there. You can even add new lines to it. The 'o' opens to new line, 'd' to remove a selected line, or just 'Esc' to go back to the main menu. So from here, let's go ahead and boot into our system. That gives you a good idea about how to edit the grub.conf file.
Notice that the colors are a little bit different in this one. This one is a blue and splash is a red. The colors indicate that the file is different in some way the red indicates that its a compress file like a zip file or a tar file. The blue indicates that it's a link. We haven't studied links yet but you'll understand that later.
So let's look at it in a little bit different way with the dash-l. So again you can see that the colors still are true. The blue and the red but now notice there's a little arrow that points over to the current directory with the dot foward slash grub.conf and all the way over here with the permissions, this area, you notice that it starts with a "l" meaning that is a link. So we're going to go in and modify the grub.conf file and we're going to use a text editor that you haven't been introduced to yet but you will learn more detail on this.
Probably more than you want to know in a later chapter. It's called vi So we're going to type vi space grub.conf. Notice there's a lot of lines up here that start with a pound sign. that pound sign indicates that it's a comment. Anything that you start with a pound sign, the system will ignore it, because it considers it a comment. So let's take a look at a few these things. Remember the default meant which item in the list it was going to select and remember in computer language zero is the first one instead of number one. Then we've got the timeout is set for zero. That means that it's not gonna pause at all.
It's just going to automatically go into the operating system. Then we've got the splash image and that tells us what the actual image is that is going to be displayed after the boot-up finishes. Then note hiddenmenu - by default that's enabled so we're going to have to comment that out in order to be able to see the menu. Then we see the term 'title' it's a fedora in here is all the information on it. Route... Where's the route drive? It's on the first hard drive on first partition. Then it gives the kernel information that this operating system is going to be using. Noticed the initrd that's the one that creates the RAM disk and loads a small version of Linux.
Now you've seen a little bit about it let's make some changes to it. In order to make a change in this, I have to type the letter i. Notice -- INSERT -- pops at the bottom that means I'm now in edit mode. I can insert, delete, change whatever. Anything that I need to. So I'm going to come up here to hidden. I'm just trying to use my mouse.. which doesn't work. All you have in the vi command is your keyboard. This has been around for much longer than what the mouse has been here.
Take a little bit time getting used to on this one. Okay, so now we've commented out the hidden menu so that means the menu will show up when you first boot your system but it's going just flashed across the screen because at this point we've got the time out set to 0. So I'm going to come over to the zero and then I'm going to change that to 10.
That means is going to wait 10 seconds before it automatically picks the default setting which is up here on this line. So at this point we have now changed to where we can see the menu it will wait 10 seconds before it picks the default operating system and in this case right now there's only one, the Fedora. So when the menu shows up that's all we would see So let's add another one. Here we're going to add another title. Let's call it floppy disk that way you could create a floppy disk to boot from and you would have the option to pick that option from the menu Now we have to put the route information so we tap route and in this case we're going to use a little bit different command and it's called routenoverify and then we're going to put the drive that it is on and since you don't partition, floppy drives there's no partition number.
Okay, with that routenoverify means is the system doesn't have to recognize the OS for it to boot from it. You would use this like if you're going to boot a Windows system, for instance. Then we go to the chainloader and we put plus one; which means that it's going to read one sector from the start of the partition that allows it to boot from the floppy. Okay, so we have changed the hidden menu.
We've commented that out so now we'll see the menu. We've changed the time out to 10 so before the default selection is made then we have a chance to change something. We've also added the option of booting from a floppy disk. To get out of the insert mode, you hit Esc, Then a colon to get to the command-line tool and type exit. That is how you get in and out of vi. That is very quick little tutorial on it. Now in order to reboot, we can do this using the init 6 command. And you will learn a little bit more about that in a future lesson too. So init 6 is the same thing as doing a reboot. Now notice 7s, 6s, 5s ... I'm gonna hit one of my arrow keys left or right I could have actually hit any key on the keyboard and it would have stopped the countdown. So now we are at the GRUB menu option. So we have a choice of either of booting into Fedora or to the floppy disk. Notice Fedora is your first on the list so that's what the default boot is going to be.
Notice the text underneath the box; Use the up or down arrows to select which entry is highlighted. Press enter to boot to the selected OS. You can use the letter e to edit commands before you boot, you could press a to modify kernel arguments before booting, or c to go into a command-line. Let's talk a little bit about the a command to modify the kernel arguments. One of the things that will cover shortly is the run level so if you wanted to you could change the run level. I'm going to press the a key and it takes you to a prompt that allows you to make modifications to the the kernel.
If I wanted to change to say, run level 3, I would just happen number 3 at the end of that line and hit enter, but I don't want to make that change. Let's select the Fedora and boot into it. Now that our system has booted, we will sign in and we're going to add a little bit more to our grub.conf file. If you want to password-protect this file, you'll need to modify it again and add a couple more commands. So let's get logged in first and then we'll go to a command prompt and then we'll go to a terminal session. First thing that we need to do is open a terminal session. I like to use the terminal session rather than console because it gives me a nice white background and I also have some options and pull down menus. So the first thing that we have to do is login as the root user. Again, remember we know that we're in as root, because we have the pound sign (#). Now we're going to use a different text editor to make further modifications.
This editor is called gedit and rather than changing to the directory, we're just going to go ahead and type it all out. I'm going to use an ampersand (&) to indicate that I want it to run in the background so that I can continue to use my shell prompt. I hit enter and it brings up my gedit application. You can see from here that the changes that we made earlier are still there, they were saved.
Notice we've got our floppy disk information now. So now let's consider putting a password on this. It would be much safer if we could protect it to where only a certain number of people would have this password in order to get into the grub.conf and make any changes. Let's come up here, and type the word 'password'. Now of course I could continue and put a password in there, but if I did that it's going to be sitting in cleartext, and if anybody got their hands on the grub.conf file, then they would have the password.
So let's encrypt it. We're going to go back to the terminal window. We're going to use a command to encrypt the password. (grub-md5-crypt) Now er enter the new password, and retype it. That password has been encrypted. That big long line of characters is the encrypted password. So what I'm going to do is highlight that and I'm going to 'edit' and 'copy' then I'm going to go back to the gedit and I'm going to go behind the word password that we just used and I'm going to put dash dash md5 (--md5) and then I'm going to paste that long stream or the encrypted password in there.
So now we've established that we're using an encrypted password and that there is one, but at this point we haven't really applied it anywhere. We come down to right before root and put lock. So before anything happens, when we select Fedora, it will automatically ask you for a password. Let's do the same thing on the floppy disk. Now we have set a password and we've told it where we want the screen to get locked and request a password.
So from here we save our file, close the gedit. Now in order for this to take affect, we have to reboot the system again. So we're in a type the 'init 6' again to force a reboot. And then again will wait until it restarts. Now we have our system booted up. You notice that the text underneath the box has changed a little bit. You can use the arrows again to move around but you have to use the 'p' in order to enter a password and have it unlock it.
So now we typed the password, notice again it's not in clear text. Now it takes you back to the original menu that you saw last time with the 'e', the 'a', and the 'c.' - e for edit the commands before booting, 'a' for modifying the kernel arguments or 'c' for going into a command-line. So at this point, let's hit the 'e' and see what happens. It brings up the portion that was under the title Fedora. You've got your lock, you've got route, the kernel information, and the init.rd image that you're going to use. You can modify anything on there. You can even add new lines to it. The 'o' opens to new line, 'd' to remove a selected line, or just 'Esc' to go back to the main menu. So from here, let's go ahead and boot into our system. That gives you a good idea about how to edit the grub.conf file.