Thursday, January 29, 2009

Adding Ubuntu-style sudo To Fedora 10

One of the neat things about Ubuntu is the absence of a discreet user account for root. This was an unusual idea when it was introduced a couple of years ago, and I myself, had some initial doubts about it. But that was then and this is now. I have come to really enjoy this feature.

I recently installed Fedora 10 on one of my test systems and decided to see what was involved in getting a similar feature in Fedora.

The sudo command is governed by a configuration file named /etc/sudoers. This file defines the users who are allowed to use sudo and precisely what commands they are allowed to execute with elevated privileges. I have written definitions for this before, so I took a look at the Fedora 10 sudoers files to see how to add myself to the list of users that can execute any command as root.

What I discovered was that the Fedora 10 sudoers thoughtfully provides the following lines:

## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

This definition states that any user belonging to the group wheel will have full access to all commands. Just what the doctor ordered!

So this leaves me with two things to do:

  1. Uncomment the line in the sudoers file to enable the definition.
  2. Add myself to the wheel group.

The first task is pretty easy. I just fire up vi (as root) and edit /etc/sudoers. I only need to remove the leading pound symbol to make the change:

## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL


The second task is not very hard either. I bring up the graphical (yes, I'm cheating) user configuration tool and select my user account and press the "Properties" button, then select the "Groups" tab on the properties dialog. Scrolling to the bottom of the list, check the box labeled "wheel":


Press OK and we're done!

Here are a couple of questions for all you geniuses out there:

  1. How would you add yourself to a group using only the command line tools?
  2. What is the history and meaning the "wheel" group?

Have fun!

Monday, January 26, 2009

A "Command Line To The Rescue" Story

As you may recall from my earlier review of my new Dell desktop, I bought it to replace my previous Dell desktop, a Dimension 2400. Over the last couple of weeks I have installed a couple of distributions on my old system. First the Windows 7 Beta (the first installation of Windows in my house since 1996), a sad story that I hope to write about soon, and over the weekend I formatted over that horror and installed Fedora 10.

I've used a lot of Red Hat products over the years and I favor it for administration, however, I have a growing fondness for Ubuntu because it seems to deliver the best desktop user experience. When it comes to Red Hat stuff though, I'm pretty expert at installing it.

Now I have to digress a bit and talk about a phenomenon I have discovered about Linux. It is often useful to think about Linux as though it were a living thing. It's been said that Linux is based on evolution, not "intelligent design." This means that Linux evolves naturally in a series of fits and starts, rather than being the result of some grand plan. This is the opposite of proprietary software, which (if done properly) is the result of careful planning.

What this means is that sometimes a subsystem in Linux goes away and is replaced by another re-written replacement that addresses a need. And, of course, programmers prefer to re-write code rather than maintain old code. Anyway, this periodic "churn" of code is natural to the process.

The problem is that sometimes things that worked in previous versions stop working in the new versions. This is fairly common Linux, and it's perhaps its most off putting characteristic.

One case in point is the display driver for Intel integrated graphics chips. Admittedly, some of these chips really suck, especially the earlier ones. The new ones are better and also get official driver support from Intel. Over the last year or so, Linux distributions have been deploying the new "intel" driver replacing the previous "i810" driver. The new driver is in every way much better than the old driver, except it doesn't like the older chips very much.

This brings us back to my Dimension 2400, which, as you may have guessed by now, uses one of the old chips.

So I pop the Fedora 10 install DVD into the drive and reboot the machine. The installer starts and gets to the first graphical install screen and completely hangs. Dead, inert. It doesn't look like I'll be doing a graphical install this time.

I power-cycle the machine and just as the DVD starts to boot, i press the escape key and get:

boot:

Wonderful! A boot prompt. Now I know what to do. I enter:

boot: linux text

which instructs the boot loader to boot the kernel called "linux" and pass the argument "text" to the system. On a Red Hat style systems this will invoke the text mode installer. I answer all the prompts and the install gets underway. While I have some time to kill, I Google for a way to get the graphics working again. From my search, I determine that the problem isn't so much the new driver but rather that, by default, the new driver uses a new "acceleration method" called "EXA" rather than the previous method called "XAA". Making a one line change to the /etc/X11/xorg.conf file will cause X to revert to the old method and solve the problem.

After the installation is complete, I reboot the machine and it comes up in text mode. This is caused by a configuration file called /etc/inittab which contains a setting for the default run level, which is 3 for text mode and 5 for graphical mode on Red Hat style systems. In text mode you get a login screen:

Login:

I log in as root and create a personal account for myself:

useradd bshotts

passwd bshotts

After I create the account and set the password, I press Alt-F2 to get to the second virtual console. There I log in as bshotts and try to launch X. I do this by entering the command:

startx

The X server starts and almost gets to the desktop before it chokes again. Looks like it's time to fix that xorg.conf file. I restart the machine and and log in as root again. I go looking around in the /etc/X11 directory and notice that there is no xorg.conf file. This is because with modern X servers, the file is no longer required, as all the configuration is done dynamically at runtime which, in concept, is great when it works.

Bummer.

I think to myself, "there must be some kind of configuration program for X," so I start digging around in the man pages. I discover that the Xorg program has an option called -configure that will create an xorg.conf file based on the server's best guess of what the correct configuration should be. You must be root to use this option so I give it a try:

Xorg -configure

and it creates a file named xorg.conf.new in root's home directory. I copy this file to /etc/X11 which is where X expects to find it:

cp /root/xorg.conf.new /etc/X11/xorg.conf

Next, a little editing with vi and I add one line to the "Device" section of the file:

Option "AccelMethod" "XAA"

After saving the edited file, I login in as bshotts and try the startx command again and low and behold, I have a working desktop! I confirm that the graphics seem correct and log out of GNOME. This returns me to the text console. Since I want the system to work in graphical mode by default, I need to change the default run level. I do this by returning to my root console session and editing the /etc/inittab file. I change the last line to read:

id:5:initdefault:

changing the "3" to a "5" to set the run level to graphical. After saving the file I reboot the machine and everything works. New installation successful.

So what does all this teach us? It teaches us that sometimes there is no substitute for a good command line. A command line can work wonders. It teaches us that, with enough digging around, most problems are solvable. And most of all, it teaches us you should keep learning and never give up.

Hope you had a good weekend too!

Interesting Story In The NYT

In my earlier post about the effect of the Asus Eee PC, I explained that it showed how Linux can be used to create "disruptive technologies." The New York Times seems to agree.

Sunday, January 4, 2009

Why use Linux?

I recently received this thoughtful question from a concerned reader:


Hi,

My name is Allan. I´m from Costa Rica. First of all, let me congratulate you because it´s a little bit hard to find a good Linux site that explains everything about the shell (and how to start using commands) and how Linux works in a friendly clean way. I have always been interested in Linux (since I was 12 years old more or less, now I´m 25). But I´m still a rookie using it. Unfortunately most of us have been some kind of forced to depend (exclusively) on Windows because of all the software available, the GUI and the easiness of using it. We all complain about how bad Windows works, that´s why I´m trying to be more involved on Linux. Yesterday, I just installed Ubuntu 8.10 Intrepid. Great OS so far.

I do not want to bother you, you should be very busy, but I have one big question. How can I stop using Windows if I need it for work and personal use (software like CS3, Paint Shop Pro, Ulead Video Studio, among many others). Maybe any Linux tech would tell me to look for an alternative GPL software. For example for Office, the option would be Openoffice (very nice soft!) but its not perfect or good enough recognizing many characters or text formats. For CS3 or Paint Shop, the option would be Gimp (nice one too) but it lacks of better user friendly funcionality or editing options. Maybe you can do almost the same thing with it but it´s going to take you a lot of time work. I could give you many examples like those, but I think you already got the point good enough.

Please do not think that I´m saying that Linux sucks, that´s not it at all, what I´m trying to say is that I realize that you all are working to make it better and better each day, more user friendly, more attractive for other branded companies (like Nero, Skype, Kaspersky, etc) but what does it take to let Linux runs everything what Windows runs. I have heard about Wine, but I also heard that only works fine on some specific softwares.

I just wanted to share my point of view. Maybe you can share yours with me so that I can understand better Linux.


First off, thank you Allen for taking the time to write. You raise an interesting issue that I'm sure confronts many people looking to migrate from Windows to Linux.

Changing computer platforms is a challenaging problem for anyone, not just those seeking to move from Windows to Linux. It really boils down to a question of cost versus benefit.

So what are the costs of switching? Obviously they are having to learn new applications and perhaps worse, migrating your data to work with your new applications. We all experience this when switching an application even if no platform change is involved. Using an application involves a certain amount of investment on the part of the user. An investment in time needed learn the application and the time to reshape his or her "world" of data to fit the confines of the application's needs. If you have been using a particular platform and its applications for a long time, you probably have a lot of investment in it. So for many people the costs are high.

But what about the benefits? Those are a little harder to quantify. First, there is the economics which should be rather cut and dry, but, for many personal computer users (as opposed to business users), it is not. If you actually paid for Photoshop, Office, and the other software you mention, you're talking about a lot of money (potentially thousands of dollars) spent on your application set. However, many personal computer users, don't bother with the formality of license compliance and simply use unauthorized copies which can be had to no cost. Therefore, for many people, Linux offers no economic advantage.

The second benefit is this nebulous thing called "freedom." Some people express this in somewhat abstract terms, saying that it is a virtue in its own right. I tend to be a bit more pragmatic. I think that free software offers distinct practical advantages over proprietary software. I like the fact, for example, that I can install Linux distributions all day long and never worry about having to call a vendor and ask for permission to do so. I like that fact that since the source code is freely available, many people can offer technical support. I like the fact that I never encounter, timed demos, "crippleware", and "lite" versions of products. Any time I want to install something, I can just install the full version, no strings attached.

Then there are the technical benefits of using a Unix-like operating system. Things like virus and malware resistance, file systems that don't require periodic defragmentation, a powerful command line interface, and the potential for almost limitless customization.

While these benefits are clear, many people do not have a clear picture of what a migration means. For many people who want to move from Windows to another platform, what they really seem to want is a "Windows" that does not have the problems that they have been experiencing. So many times you hear, "I'd change to Linux but I tried it once and it was different from what I'm used to."

Yes, Linux is different. Linux is very different and to successfully move to it (or any other platform for that matter) you have to be willing to accept change. Some people really cannot do this. Their minds are not built that way. They learn just enough about "the computer" to do their jobs by rote. Platforms just don't matter to them.

Platforms matter to people who enjoy and care about computing. I use Linux as opposed to Windows because I really like computers. I enjoy using them and learning about them. I find that Linux helps me enjoy my computer much more than any version of Windows ever did.

As to your concerns about OpenOffice.org and GIMP versus Office and Photoshop, yes, they are different too. I'm currently writing a book with OpenOffice.org and I have found it very satisfactory. I used to write a lot with Word and it was fine too. I don't see a lot of practical differences in what each program does, but there certainly are surface differences which may be difficult for some people. I suppose that the same may be true with GIMP and Photoshop. I've never used Photoshop so I can't really comment, but from reading the comments of others, I sense that many people reject GIMP out-of-hand because it's not just like Photoshop. Both are very capable programs and the field of digital image processing is an extremely technical one which makes any truly capable application dauntingly complex. But with the exception of of deep color support, and some pre-press functions, GIMP is very comparable to Photoshop for many tasks. I use it routinely in my photographic work.

To sum up, change requires, well, change. Forward progress sometimes means giving up old ways of doing things and learning some new ones. For anyone attempting it, the question remains, "is it worth it?" and only you can know the answer to that.

Hope this helps.