Understanding the Linux File System


To really use Linux effectively, you need to understand the basics of the Linux file system. A file system is a collection of files that contain various kinds of data (in some cases, for example, words and sentences) and the collection of organizational details with which the files are stored. These files and the details that organize them are all maintained together inside a computer system, and together they make up a file system. All modern computer operating systems use a file system to organize information, in much the same way that every office has a filing system for its documents. The Linux file system, however, differs in important ways from the file systems you might have used in Windows or Mac OS. To illustrate these differences, we compare the Windows and Linux file systems in the following sections.

Many Trees, Many Roots: The Windows File System

As a refresher to those who are already familiar with Windows, in Windows the C: drive contains files of various types along with numerous file folders, each of which can contain more files. All these files and file folders are collectively referred to as the file system of the C: drive. Like most operating systems, Windows allows file folders to contain other file folders in addition to data files. This capability creates a structure that commonly is referred to as a tree, as shown in Figure 5.3. At the base of the treein this case at the C: drive itselfis what you can imagine to be a kind of root.

Figure 5.3. In general, file systems look like a tree; here, in a diagram showing some of a Windows file system, the hard drive itself is the root of the tree.


In Windows, each storage device is assigned a drive letter and contains its own set of files and folders. Each drive letter is therefore the root of its own file system and, thus, of its own file system tree. Mac OS assigns each storage device in the computer its own file system in much the same manner. An illustration of this concept appears in Figure 5.4.

Figure 5.4. In Windows systems, each storage device has its own file system. The system has many trees and many roots.


One Tree, One Root: The Linux File System

Linux and Unix file systems, on the other hand, aren't organized like Windows or Mac OS file systems. Any Linux computer has only one file systemand thus one tree. The most fundamental location or starting point within the Linux file system is not a hard drive letter like C: or D: but is rather a file folder that contains all other devices, files, and foldersa conceptual storage area known simply as the root of the file system. The Linux file system's root is referenced with a forward slash (/). As is the case in Windows and Mac OS, Linux is capable of using multiple storage devices at the same time; however, in Linux each storage device is positioned within the main file system tree, rather than being the root of a separate, independent file system tree. You can see this system in Figure 5.5. Incorporating a storage device into the main file system tree in Linux is known as mounting a device onto the file system tree.

Figure 5.5. A Linux file system tree with additional storage devices mounted at /usr/X11R6, /home, /boot, /mnt/cdrom, /mnt/dvd, and /mnt/zip. Each device enlarges the single, unified tree, and the system still has only a single root.


Files, Folders, and Directories

In Linux, as is the case in Windows or Mac OS, the data that you work with is stored on a hard drive somewhere in the file system, in individual data files. Each file has a unique name and can be opened by one or sometimes several applications or programs that are designed to access the data inside.

Windows and Mac OS users often use folders to organize these files, and so do Linux usersbut in Linux you may also hear them referred to as directories. Although the names are different, the concept is precisely the same (throughout this text, we'll use the terms folder and directory interchangeably). If you've never encountered one before, a folder (or directory) is a kind of container in the file system for holding data files of various types or for holding still more folders (or directories). Folders are used primarily as an organizational tool, just like file folders in an office.

The root of the Linux file system is commonly referred to as the root directory because it contains all the other files and folders in the file system.

Paths

Most computer systems that get used on a day-to-day basis will eventually come to hold a large number of data files in their file system(s). In nearly all instances, for organizational purposes some of these files end up being stored inside folders that themselves reside inside other folders (refer again to Figures 5.3 through 5.5 if you need help visualizing this tree-like structure). With such a mishmash of nested files and directories, it's often helpful to be able to describe the precise location of a file within a file system in some kind of shorthandfor example, if you want to tell a friend exactly where in the file system a particular file has been saved.

In Linux, this shorthand is called a path, and it's written like this:

 /directory1/directory2/directoryN/filename.ext 

This particular path shows that a file called filename.ext is stored inside a directory called directoryN, which itself is stored inside a directory called directory2, that is in turn stored inside directory1, which resides in the root directory (/).

This kind of shorthand is called a path because, when read from left to right, it provides the path that you need to travel along through the Linux file system in order to reach the file. For example, consider this path:

 /cities/parks/trees/oaks.txt 

If you were to begin at the root directory (/) of the Linux file system, to be able to find the file oaks.txt, you would need to first open the directory called cities. Inside cities, you would need to find and open another directory called parks, and then inside parks, a directory called trees. Only in the list of files contained in the directory called trees would you finally find the file oaks.txt. A few more sample paths and their explanations can be found in Table 5.1.

Table 5.1. Sample Linux Paths

Path

Explanation

/

Refers to the root directory

/home

Refers to the directory home, which is contained in the root directory

/usr/X11R6/lib

Refers to the directory lib in the directory X11R6, in the directory usr, which is itself in the root directory

/usr/share/xmms/Skins

Refers to the directory Skins in the directory xmms, in the directory share, in the directory usr, which is itself in the root directory


The Home Directory

If the concepts of paths, directories, and files all seem a little fuzzy to you right now, don't worry; you're going to get some hands-on experience in just a moment.

You've already learned about one special directory in Linux called the root directory that contains all other directories and files. Before you're ready to use the text editor's Save As dialog box to save the text you've typed, however, you need to know about one more special directory, called the home directory.

When a Linux user creates and saves files, receives email, scans an image on a scanner, or performs any number of other common tasks, any data that the user needs to store in a file on the hard drive is generally placed somewhere in the user's home directory.

Every user account on a Linux system has its own home directory; your home directory usually shares the same account name that you use to log in to your Linux desktop and is stored in /home. So, if you log in as jack, your home directory is located at /home/jack, and any files you save or new directories you create while logged in as jack are generally placed in /home/jack. If you log out and another user subsequently logs in as jill, any files or directories she creates after logging in are usually stored in /home/jill.

Home Directories and My Documents

You can think of home directories as the My Documents folders of the Linux world. Just as you save your files in My Documents when you use Windows, you save your files in your home directory when you use Linux.


In this way, Linux allows for the creation of many user accounts, while at the same time keeping all users' files separate from one another. This system of organization also keeps the file system uncluttered by ensuring that most of the day-to-day files that a user creates are stored in one single location that's owned by that user.



    SAMS Teach Yourself Red Hat(r) Fedora(tm) 4 Linux(r) All in One
    Cisco ASA and PIX Firewall Handbook
    ISBN: N/A
    EAN: 2147483647
    Year: 2006
    Pages: 311
    Authors: David Hucaby

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net