Root 101

If you don't “get it,” you probably haven't got it

by David Baker, 28 February 2003

For many who are accustomed to single-user operating systems like Windows 98 or Mac OS 9, the concept of root is an unfamiliar one. This article is intended to help explain what root access is, whether you need it, what you can do with it, and how you can get it.

Of course, as is common with technology terms, there are two very different definitions of root. Here is an explanation for one, just to get it out of the way:

For example, a file in the root directory of a computer running Windows would have a file path such as c:\MyFile.doc. A file in the root directory of a computer running Mac OS 9 would have a file path such as Macintosh HD:My File. A file in the root directory of a computer running a Unix-based operating system (including Mac OS X) would have a file path such as /myfile.txt. Note that, in Unix, the first slash in a file path denotes the root, or highest-level directory on that drive or volume.

As interesting as that is, it doesn't really relate to the discussion at hand. That would be the other meaning of root:

This leads to another important definition:

So, this is all well and good, but it doesn't explain what root access really is. Simply put, it all comes down to log-in permissions. On a Unix system, access and permissions are tied in to a user's log-in, which is made up of a username and a password.

When a user logs on to a computer running one of the various flavors of Unix, he is prompted to enter his username and password. The system then checks its roster of users to determine if the password and username match. If the user logs in with the username root, using the root password, he will be given permission to do lots of things that other users aren't allowed to do.

Here are just a few examples of some operations that may require root access:

Many of these examples are things that users are used to doing in their single-user systems. In fact, many users might feel like they are entitled to do these things. However, with multiple-user Unix-based systems, hardware and software configurations are closely controlled because they affect multiple people. Changes made while logged in as root can create potentially disastrous repercussions that affect all users on the system. As we all learned from the movie “Spiderman,” with much power comes much responsibility. Here's a little comparison that might make this concept a bit more clear.

A houseConsider Harry Homeowner, who owns a split-level 3 bedroom house on a quarter acre in Outer Suburbia. Since Harry has the key to the front door, he has access to his entire house, from crawlspace to kitchen to bedrooms to attic. He — and the bank — own the whole place, so he can pretty much do as he please.

If Harry wants, he can install a new turbo-flush toilet or convert his garage into a studio apartment. He can also replace the GFI recepticles in his kitchen and bathrooms with unprotected outlets, or take a sledge hammer to his hot water heater. Not that he should do either of these last two things -- the point is, he could.

 

ApartmentsContrast Harry's situation with that of Albert the Apartment dweller. Albert rents a four-room space (living room, kitchen, bedroom, bathroom) in a multi-story complex in Inner Urbania. Albert has access to his own unit, which is protected from outsiders by a deadbolt and chain lock. In addition, Albert also has access to common areas such as hallways, laundry facilities, and the mail box facility.

Neither Albert nor his neighbors has the right to enter anyone else's apartment. Moreover, Albert and his fellow residents are prohibited from entering places such as the boiler room, the broom closet, and the main electrical room. The only person with keys to every door in the complex is the building superintendant (or super), who is has the run of the place. The super controls facility services (such as water and power), authorizes structural changes to the building, and can even enter tenants' apartments if he needs to.

 

Running a single-user operating system like Windows 98 or Mac OS 9 is a bit like living in a single-family home. Harry's relationship with his house is like a user's relationship with a single-user OS. A Windows user running Windows 98 can monkey around with DLLs, edit his Windows registry, and throw .INI files in the recycle bin to his heart's content. A Mac user running OS 9 can fiddle with extensions, take ResEdit to his System resources, and play a little game called “hide the Finder.”

In other words, a Windows 98 or Mac OS 9 user is totally free to screw up his own system. All of the files that are critical to his computer's health are accessible and vulnerable to tinkering. If he knows what he's doing, this user can fine-tune his computer's performance. If he doesn't know what he's doing, he can easily turn his machine into a really expensive paperweight.

In contrast, Unix systems are designed for multiple users. Like an apartment building, many people can be using the system at the same time. Because of this, only one person -- or a few select people -- are given permission to make changes that affect the whole system. While a tenant can turn off the lights in his living room, a super can shut off power to the entire apartment complex. Of course, there would have to be solid justification to do so. By using root access appropriately, super users can keep their “apartment computers” running smoothly.

If you're new to Unix, chances are pretty good that you have some more questions about wielding the power of root. Hopefully, you'll find the answers to those questions below.

>> How can I tell if I have root access?

As the title of this article suggests, with root access, if you don't know whether you've got it, you probably don't. However, it is possible to be logged in as root without knowing it. There are three different ways to find out whether you are root. The easiest is to look at your command prompt. Generally, your prompt contains your current username. So if you're logged in as root, you might see something like this:

In this example, we're logged in as root, working in the root directory of the system (as indicated by the “/” in the prompt).

If that seems too simple, there are some special commands that will tell you if you're root. At the preceding command prompt, you could enter: