Last month we started talking about the "big picture" differences between the Linux filesystem and the Windows filesystem. Aside from the high-level differences, there are also major differences in the directory structure under Linux and Windows. If you remember from last time, we discussed the fact that the filesystem is actually organized as a "tree" with a "root" directory at the top level symbolized by a forward slash (/) under Linux, and a back slash (\) under Windows (see Figure One for a diagram of how the Linux filesystem is structured). So, with that starting place in mind, let's take a look at the directories hanging off of the root directory under Linux and comparing them to their Windows counterparts. The first stop on our tour:
|Figure One: The Linux filesystem tree shows how directories are organized.|
Last month we started talking about the “big picture” differences between the Linux filesystem and the Windows filesystem. Aside from the high-level differences, there are also major differences in the directory structure under Linux and Windows. If you remember from last time, we discussed the fact that the filesystem is actually organized as a “tree” with a “root” directory at the top level symbolized by a forward slash (/) under Linux, and a back slash (\) under Windows (see Figure One for a diagram of how the Linux filesystem is structured). So, with that starting place in mind, let’s take a look at the directories hanging off of the root directory under Linux and comparing them to their Windows counterparts. The first stop on our tour:
/bin and /sbin
The /bin and /sbin directories serve as the home for a lot of small executable programs that most people think of as part of the operating system itself, but they really aren’t.
For example, the ls command, which you would type at the command line to “list” the contents of a directory is stored in /bin. The “bin” part of the name is yet another example of Linux/ Unix style shorthand. It stands for “binaries,” which is what übergeeks sometimes call programs. Under Windows these files are both stored in C:\WINDOWS and C:\WINDOWS\ SYSTEM (and its subdirectories).
/boot is where the Linux kernel is stored. People often use the term “operating system” to refer to the entire operating system environment, but that is not really correct. Strictly speaking, the kernel is the operating system itself. It is the program that controls access to all the hardware and devices your computer supports and allows multiple programs to run concurrently and share that hardware. Most of the other programs that are a part of the operating system environment are stored in /bin or /sbin (as we just mentioned). The closest thing to this under Windows is a combination of the DOS boot image in C:\ and a bunch of DLLs stored in C:\WINDOWS\SYSTEM.
/dev is where your device drivers live under Linux. Well, not really. The drivers themselves are not stored here, but this directory contains special files that allow programs to talk directly to device drivers. This allows programs interact with devices easily.
/etc holds your system configuration files. You’ve probably heard that under Linux almost everything, from user passwords to system initialization files to your X configuration, is controlled by settings in plain-text files. That’s true, and they’re almost all stored in /etc and its subdirectories. (User-specific settings are stored in your home directory, which we’ll get to shortly.) Windows still uses a mix of .ini text files and the dreaded Registry to store this same information, with the files contained in C:\Windows\All Users, C:\ Windows, and sometimes directories under C:\Program Files.
/home is where the heart is, or at least it’s where your personal data is stored. If your username under Linux is fred, then there will be a directory named /home/fred that will contain your personal directories, files, and options settings for the programs you use. You can use a tilde (~) as a shorthand to refer to your home directory, so fred’s ~/ work_stuff directory is shorthand for /home/fred/work_stuff. The one exception to the /home/<username> convention is root, the superuser, whose home directory is /root (not /home/ root, and not to be confused with the root-level directory (/), which is also referred to as “root.”). Windows does not separate users this strictly, which is why you’ll your desktop settings in C:\Windows\All Users\<username> and everyone’s files lumped together under C:\My Documents.
/lib holds your system libraries, which are parts of programs (yet more “binaries”) that Linux itself and your other programs share. The equivalent to a Linux library under Windows is a DLL. Normally you won’t have to bother with this directory, and you can just let Linux and your programs worry about it. Windows isn’t very careful about where it stores DLLs, which is why you find them scattered hither and yon in system and program directories. This has created the infamous “DLL hell” problem, which occurs when lots of different Windows programs install different libraries in ran-dom directories, and programs become confused about which library they should actually be using. Windows programs also have an annoying tendency to overwrite existing DLLs without regard for whether or not a different program actually needed that DLL.
/mnt (pronounced “mount”) is one of the more interesting stops on our tour. On most systems /mnt will have subdirectories like /floppy, /cdrom, or /zip for your removable media drives. When you mount a floppy disk, its files will appear in /mnt/floppy, since Linux has no concept of drive letters (like A:).
The placement of these mount directories is one of the ways Linux distributions have differed over the years. Some place the device directories directly under / instead of /mnt, and some distributions use an automount program that mounts and unmounts drives for you, but makes their contents show up in a different directory from /mnt/<drive name>. While Windows has traditionally used only drive letters, Windows 2000 supports mount points, which lets you mount drives anywhere in a directory tree.
/proc is definitely the odd duck of the Linux filesystem since it’s not really there — it’s a “virtual” part of the file- system. The “files” in /proc are not really files. Instead, they are “virtual” files that contain a ton of information about your system. For example, if you enter the command:
you’ll see a nicely formatted table of information about your computer’s processor(s). Similarly, typing
will show you the current memory- usage statistics for your system. All this information doesn’t really live in the “files” in /proc, but Linux cooks the books, so to speak, to make it look like it does. Linux’s sleight of hand makes it very easy for users and programs to find this information.
/tmp is just what you’d expect, a system-wide temporary or work file directory that’s analogous to Windows’ C:\ Windows\Temp. (By the way, Linux has staved off a catastrophic bit shortage by spelling tmp without the “e” and shortening mount to mnt.
/usr is a directory filled with subdirectories. Many of these subdirectories contain programs directly related to or run by users, such as word processors and games. These programs are often stored in /usr/bin. Windows uses C:\ Program Files in much the same way.
Another interesting subdirectory under /usr is /usr/ src/linux, which holds the source code for Linux itself, if you have it installed. The Windows equivalent is a vault in a concrete bunker 100 feet underground, just outside Redmond, Washington.
/var is a place for files that vary a lot (hence the name), like /tmp, but its use is more formalized, particularly the /var/log directory. If you look in /var/log you’ll see a bunch of text files that Linux and various programs will add messages to, as a way of letting you know the system status, particularly when something goes wrong. You can open an X terminal under a Linux GUI and enter the command:
to see the last 25 lines of one of the more active log files. Windows does use some log files, such as C:\bootlog. txt, but it doesn’t have anywhere near the history of logging messages that Linux inherited from Unix.
Three Quick Filesystem Tips
1. Never store files in the root directory, and never create new directories directly in the root directory, unless you have a very good reason. Doing either of these things is wildly non-standard and will cause experienced Linux users to point at you, make cryptic comments, and laugh.
2. Use your home directory (/home/<username>, a.k.a. ~) to store your data, including all documents you create with your application programs. You can create subdirectories under ~ to your heart’s content and organize things however you want, but this is definitely the place for them.
3. Always remember that directory and file names under Linux are case sensitive. In other words, if you wanted to create a list of files in the same directory named “ToDoList,” “todolist,” “todoList,” “TODOLIST,” and other variations that differed only in which letters were upper or lower case, you could. This case sensitivity can also lead to mysterious “missing file” problems if you make a capitalization error in typing a directory or file name. When that happens the file is still there, of course, but you’ve accidentally told Linux or a program to look for it under a different name.
Everyone Off the Bus
This is just a whirlwind tour of the Linux file system, of course, but it should help you to explore some more on your own. Just remember that the natives are friendly, and they’re willing to give directions if you stop to ask.
Lou Grinzo is a technical writer and consultant living in upstate NY. He can be reached at email@example.com.