When a Windows user sits down in front of a Linux system, even one with a decidedly Windows-esque GUI (Graphical User Interface), several differences are likely to make even an intrepid neophyte develop a nervous twitch. But none will cause more consternation than the differences between the filesystems -- Linux has no drive letters, everything is mashed into a single directory tree, and there sure seem to be a lot of directories with similar names.
|Figure One: The root-level view of a typical Linux filesystem tree, as can be seen in KDE’s file manager.|
When a Windows user sits down in front of a Linux system, even one with a decidedly Windows-esque GUI (Graphical User Interface), several differences are likely to make even an intrepid neophyte develop a nervous twitch. But none will cause more consternation than the differences between the filesystems — Linux has no drive letters, everything is mashed into a single directory tree, and there sure seem to be a lot of directories with similar names.
If your eyes start to glaze over as you stare at the Linux filesystem, you aren’t the first. But as The Hitchhiker’s Guide to The Galaxy counsels explorers of new worlds, don’t panic. It really isn’t as overwhelming as it might appear to be. Still, there are quite a few differences between the two filesystems — enough differences, in fact, that we’ll be covering this topic in two parts.
This month we’ll take a look at some of the “big picture” differences, and next month we’ll look at the details of how the Linux filesystem is organized and compare it to Windows.
The Battle of the Slashes
A number of high-level differences between the two filesystems can trip you up. The first (and possibly the most annoying) is the great “forward slash” (/) vs. “back slash” (\) debate. It goes like this: Unix (which is the system that Linux is based on) existed way before DOS (which is the system that Windows is based on) did. Unix directory path names were separated by a forward slash. The guys who first wrote DOS wanted to imitate Unix, but they screwed up and got it wrong. So they separated directory path names with a back slash.
What this means is that if you want to refer to a file under Linux, it has
a path name of something like /usr/bin/vi. Under Windows, files have path names like C:\ WINDOWS\COMMANDS\ Chkdsk.exe. This is another great example of things being more complicated than they really need to be, for no reason whatsoever.
Who Needs Drive Letters?
Another departure from Windows is that Linux does not have drive letters, e.g., C: in its path names. This is due to a basic difference in how Linux and Windows structure their filesystems.
Under Linux, there is just one unified directory, with everything beginning at what is called the root directory. The root directory is symbolized by just a forward slash (“/”), with nothing following it. There are many directories hanging off of the root directory, as illustrated in Figure One. Each of those directories has subdirectories, and so on and so on, creating a directory “tree.” The “root” directory is the root of that tree. (OK, so it’s an upside-down tree, but you get the point.)
The process of adding a disk under Linux is referred to as “mounting” a disk. Aside from physically inserting the disk, you also need to tell Linux which directory in the “tree” you want to “mount” that disk under, and the contents of the disk appear in that directory. This creates the appearance of a seamless, “unified” filesystem. If you don’t explicitly issue a command to mount the disk and tell Linux what directory to put it in, the system won’t know that the disk is there, even if it’s in the drive.
The DOS Way
Windows works differently. Rather than having a unified filesystem, Windows has “drive letters” and creates distinctions among which drive files are stored on. Thus, the C: drive has its own directory tree, and so does the D: drive, etc. Figure Two has an illustration of the top level of Windows’ C: drive. When you add a disk under Windows, you don’t have to tell it to do anything. You just click on that drive, and Windows displays the contents. This may seem more convenient, but it actually makes it more confusing to keep track of which “drive” things are stored on, and makes it take longer to navigate the filesystem.
|Figure Two: The top-level directory tree of a Windows C: drive.|
Why Is Everything Different?
There actually is a good (or at least not stupid) reason for this difference between Linux and Windows. Before the late 1980s, hard disks and networked computers were rare outside of research facilities and large corporate data centers. As we mentioned earlier, Linux is a descendent of the Unix family tree. Unix was born in 1969 and grew up in computer science research laboratories. Since it came from a research environment, Unix grew up in a world of hard disks and networks. The guys who designed Unix wanted to integrate all of these storage devices into the Unix filesystem so that it could be navigated in a simple and logical fashion. Thus was born the “unified” filesystem and directory structure.
Meanwhile, in the early 1980s, personal computers (PCs) were just starting to move into people’s homes and small offices. These computers were designed to be affordable, not to do research, so they had floppy-disk drives (not hard drives), and no networking capabilities. The operating system that was designed to manage all of this cheap hardware was DOS (which later grew up to become Windows). DOS was more concerned with whether or not your computer had one floppy drive or two (your A: and B: drives). Later, when hard disks became more affordable, the infamous C: drive emerged. CD-ROMs brought D: or E: drives…. You get the point.
DOS and Windows were always trying to tack more stuff onto a system that had been designed for much more restricted environments. As computers, drives, and networks became increasingly cheaper in the late 1980s and 1990s, the DOS way of doing things became more and more outdated, but it stuck around because so many people were already used to it.
Oh, and one other important difference related to adding or removing disks: Under Linux, never just remove a disk from a drive without “unmounting” it first. It will really mess up Linux. Windows users do this all the time, and it isn’t good for Windows either, but no one seems to care. Under Linux, the physical drive probably won’t let you eject the disk until Linux has received the unmount command. But Very Bad Things™ will happen if you try to force it to eject the disk.
The Needs of the Many…
The multi-user nature of Unix creates one last major difference between the two filesystems. Unix was designed from the ground up to allow many different users to share one machine without stepping on one another’s toes (or files). Each user is given his or her own independent home directory (more on this next month), and that directory and any files in it cannot be accessed by other users.
Of course, at least one person needs to have complete access to the entire filesystem (including all the user directories), if only to administer things and create new directories for new users. That person is the “root” user (sometimes called the “superuser”). This is what is meant when people say they are logged in as “root.”
The point of all this is that your view of the filesystem depends on who the system thinks you are (in other words, who you logged in as). If you log in to your Linux system as a regular user, you are automatically deposited in your home directory, and you will not necessarily be able to view the contents of all the directories in the filesystem.
If you log in as “root,” you are deposited in the “root” home directory, and the entire filesystem is yours to explore. (It’s probably worth pointing out that the “root” home directory is an actual directory hanging off of the real root directory, which is represented by the forward slash (“/”). Yes, this is confusing.
That said, it can be very dangerous to log in as root and poke around the filesystem. If you make a mistake and mess up any important files or directories, there’s no telling what might happen next. As a regular user, your permissions are restricted to the point where you stand no chance of messing things up anywhere but in your home directory. Even if you are the only user of your Linux system, it is a good idea to protect yourself by creating a non-root account and doing most of your work there.
Windows, of course, was designed for a single user sitting in front of his or her own PC. It doesn’t have “super-users” or different user accounts. (Well, Windows NT and Windows 2000 do, but where do you think they got the idea from?)
When you turn on a PC running Windows, you basically own the whole system. You can erase and mess with any files you want anywhere in the entire filesystem. Try it out. Have a field day. Just be sure to have a copy of Linux nearby so that you can install it on your system after you’ve rendered Windows unusable.
Adam Goodman is the publisher of Linux Magazine. He can be reached at firstname.lastname@example.org.