Be careful using the Linux command line — it can be very addictive. You don’t have to be a hobby fanatic to enjoy the power of what’s often called “pure computing.”
But assuming you have no intention of using it any more than absolutely necessary, we continue our work in it just long enough to get the job done. The last lesson is something you’ll need to repeat on a regular basis once we get things all in place, just to make sure everything on the system is fully up to date. Yum will become one of your best friends. This time we will tell Yum to add some new packages not normally installed, but important for the desktop user. Then we will add some extra repositories so we can add the extra functions typical for home PC users.
Go back to the “Applications” menu and open the Terminal window again. Do you recall how to log in as root?
su root
type password for root blindly
Now you should see the root prompt, which should include the hash mark (#). If it’s been a few days since you last played with it, you need to run yum update
again just to make sure. Once that’s done, let’s tell Yum to add something:
yum install yum-fastestmirror yum-priorities
This translates to telling Yum we want to install Yum add-ons, the first which allows it to find the fastest mirror for that day, and then another to teach Yum how to prioritize repos to prevent getting things confused. You see, while these very nice people offer extra packages for Yum to download, it seems to work best in the long run if we make sure Yum isn’t too aggressive at pulling from these other, outside repositories.
If Yum ever complains it already has the latest of something you tell it to install, just re-issue the command without the package it complained about. However, I want you to add one new trick to prevent having to type the whole line again. Just hit the up-arrow key on your keyboard, and the prompt will display the previous commands you typed, one line at a time, in reverse order. Now, Windows XP does this with its command prompt, so it’s not exactly some wild secret trick. But most people never have any reason to find this out about Windows, whereas in Linux, sometimes the command prompt is simply the quickest and best way to get things done. So if you type something and Yum complains you’ve asked for something it already has, just hit the up-arrow key, move the cursor to the offending package name and either backspace over it, or delete it from the front, and hit ENTER again.
Now we do something a little more challenging: We are going to edit a file from the command line. However, we are going to use a very easy editor for the job — Nano. Bear with me here, as we also learn to move around with our command line prompt. It’s easier to learn from your minor mistakes if you happen to move your prompt to the place in the file system where you are working. We need to go to the place where Linux usually keeps all its configuration files. You’ve heard of the Windows Registry, some spooky place mere mortals avoid, because the most minor error can destroy the whole thing? Linux doesn’t have such a thing, but breaks up the job of keeping track of things. It may not be a better way of doing things, but most people think it’s a little easier to adjust the system, and we need to do that. Specifically, we need to adjust how Yum behaves, sort of like changing the rules.
First, let’s move to where the files are. The command for moving around is “cd” — abbreviation for “change directory.” It’s the same for the Windows command prompt. We want to go to the section of the machine where all the configuration files are kept (or most of them) called “etc” —
cd /etc
There is a space between the command and the place. You gotta type that forward leaning slash right up against the name, because we don’t necessarily know exactly where we are, and we need to be sure the “cd” command knows precisely where we want to end up. So what’s there? Type simply the two letters ls
(lower case L and S) and you’ll get a list of what’s there. You don’t have to understand it just yet, but you’ll notice the list includes the place we want to go next. That’s the place where we keep the Yum stuff separate from everything else. So we move again:
cd yum.repos.d
This time we didn’t need the forward slash, because that next directory was right there in plain sight. Do another “ls” and see what’s there. You should at least see this: CentOS-Base.repo
Notice it says “repo” for repository. We need to change this file. We open it with the Nano editor like this:
nano CentOS-Base.repo
Another shortcut: If you type enough of the name of any file in the directory where you are, and the prompt can differentiate it from all the others, and you can stop typing and simply hit the TAB key. The prompt should figure it out from there, and finish it for you. So if you just type nano Cent
, for example, and hit TAB, it should finish typing for you. Hit ENTER.
The file will open, and you’ll see this editor gives hints at the bottom of the screen. All you really need to remember is the symbol called “caret” (^) is the simple way of indicating you should hit and hold down the CONTROL (or CTRL) key before you hit what is next to it. So ^X
means the same as CTRL + X
. Let’s edit this file.
What you see is a series of repeating entries bunched together in groups of five or six lines each. You can identify what each group is called by the name in the square brackets, so the first one near the top should be [base]
. Go down about five lines, and the sixth should be a blank line. Stop on that first blank line, so that the line above looks like this:
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
and the line below looks something like this:
#released updates
Now, if your flashing cursor is between those two, hit the ENTER key. Just like any other editor you have probably used before, it will insert another blank line and the cursor will jump down one. Hit the up-arrow key one time and get back up next to the line of text above. Type in what you see here:
priority=1
There are no spaces there. Now, repeat that process three more times, so that our added line appears below each of the four sections named with square brackets: [base], [updates], [addons] and [extras]. If you have any other lines below that, give each of those sections a priority=2
— you might see [centosplus] and [contrib].
Your file should look like the one linked here. If you are just extra cautious, feel free to copy mine to your machine. If you’ve ever used a browser, you’ll know you can right-click and “save as” or something like that.
If you are pretty savvy, you’ve figured out by now the repositories labled base, updates, addons and extra are generally the most important ones to you, and the others are almost as important. Let’s save that file as it is by using the visible commands at the bottom of the window. Now, this is Linux and some steps are broken down into each baby step, so we have to save it as a separate action from closing it. So first type ^O
(CTRL + O) then ^X
(CTRL + X). The editor should disappear and you’ll be back at your prompt.
Congratulations! You have just edited a configuration file and nothing broke. Okay, now we need to tell Yum things have changed a bit. So do that — yum update
. It may say something slightly different from in the past, but for now we’ll just be glad if Yum doesn’t complain, choking on what we did. If there’s no complaints, we can take a break and get ready for the next step. Be sure to log out of the root account by typing exit
at the prompt. Yes, we’ll be using the command line Terminal again, so get used to it.
If Yum complains, you can post your sorrows in a comment below and I’ll try to help, perhaps even explain how to copy my file to the place where your machine can use it. Mine works.
Pingback: Linux Migration for the Home PC User, Part 7 « Just Passing Through