Linux Migration for the Home PC User, Part 5

By Ed Hurst | Posted at 4:49 AM

Be careful using the Linux command line — it can be very addictive. You don't have to be a Linux hobby fanatic to enjoy the power of what's often called “pure computing.”

Previous Parts in this Series

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. Our previous lesson is a procedure 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 allows it to find the fastest mirror for that day; the second teaches Yum how to prioritize repos to prevent getting things confused. You see, while these very nice people with their repositories offer 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.

Sometimes when you ask for more than one package at a time, if Yum ever complains it already has the latest of something you requested, 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 command you typed. Keep hitting that key and it will continue to display more of them, 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 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:


and the line below looks something like this:

#released updates

Now, move to the end of that “gpgkey” line using your END key, then 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. With your cursor at the beginning of the blank line, type in what you see here:


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. Then you'll have a copy for reference saved on your computer.

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 with our edits 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.

Ed Hurst is Associate Editor of Open for Business.

Join the Conversation

2 comments posted so far.

Re: Linux Migration for the Home PC User, Part 5

Just wanted to mention. (Doing it in GUI)

When the computer boots up log in as root. Then you can use a graphical editor. (Danger - increase of risk probably minor. Just don’t make a habit of it.)

Go to the menu. Applications Accessories Text Editor File Open and then File System etc yum.repos.d Edit yum.repos.d and save it like you normally would with a text editor.

Log out and log back in as yourself to update.

To update go to the menu Applications System Tools Software Updater

(Just a note: I don’t log into the Graphical environment as root. It is a little more dangerous and I use the command line which is faster.)

But Linux is no harder to use than Windows and its funny that when trying to get users to migrate Linux guru’s don’t show a/the GUI way of doing the same task.

Posted by Carlton Lee - Aug 13, 2009 | 12:38 PM

Re: Linux Migration for the Home PC User, Part 5

We introduce the command line because that is integral to the way Linux operates. Migration means migration of habits, as well. A significant amount of Windows stuff can be done that way, but there seems this elitist culture among Windows gurus trying to hide it from novices. Sometimes the GUI route is an obfuscation.

Posted by Ed Hurst - Sep 17, 2009 | 4:43 PM