-->
Previous Table of Contents Next


File Types

Under Linux, a file can be one of several types:

  Ordinary files
  Directories
  Links
  Special device files

We’re not going to spend a lot of time discussing each of these file types; you should be able to see the difference between them in the short explanations here. If you want more information about UNIX file types, check out one of the UNIX texts listed in Appendix A.

Ordinary Files

Ordinary files win the Linux prize for truth in advertising; they tend to be rather ordinary. Generally speaking, you’ll spend most of your time working with ordinary files of some sort:

  Text files are made up of ASCII text. For example, when you create a file in emacs, you’re creating a text file. In addition, if you create source-code files for use in programming, you’re creating text files.
  Data files may contain special characters not contained in the ASCII set. For example, the xv graphics editor creates and edits files in various graphics formats. Because these files contain non-ASCII characters, they are data files. The same would go for files created by a database manager or a spreadsheet manager.
  Command text files, also known as shell scripts, contain ASCII characters but are marked differently from other Linux files.
  Executable files are binary program files that are created when source-code files are compiled.

Directories

Directories are, well, directories. Under Linux, a directory is also a file that contains information about the directory. (Talk about the ultimate in self-referential logic…) You’ll learn more about directories soon, but the important thing to know is that directories can have the same sort of limitations—i.e., permissions—as can files.

Links

A link is a reference to another file within the filesystem. This allows a file to be in two (or more) places at the same time—in its original file location and at the reference elsewhere in the filesystem. You’ll learn more about links later in this chapter.

Special Device Files

In a sense, you’ve already covered this type of file in Chapter 2, when you learned how Linux refers to various portions of the PC architecture, such as /dev/hda for the hard drive. These references are called device files, and they are used by Linux to represent physical portions of the PC. Under Linux—and under UNIX, for that matter—everything is a file, whether it a collection of data, a device file representing a physical piece of hardware (such as a printer, disk drive, etc.), or the kernel of the operating system itself. Similarly, even if you’ve installed Linux on a PC with multiple hard drives, you’ll never see a difference in the way Linux treats the separate drives; there will be only one large filesystem.

How Linux Organizes Files and Directories

Most important Linux commands deal with the management of files and directories. Therefore, it’s important that we take a moment and explain exactly how Linux treats these files and directories.

Like DOS, Windows, the Macintosh OS, and other versions of UNIX, Linux stores files in a hierarchical fashion; files are stored in directories, and directories (or subdirectories) are stored in other directories. The only directory that’s not a subdirectory of another directory is the root directory. This directory doesn’t have a name (like bin, as seen in Table 4.1). Instead, the root directory is indicated by a slash (/). This is the opposite of MS-DOS, which uses the backslash (\) to indicate the root directory. The directory above the current directory in the hierarchy is called the parent directory. The Linux installation process creates quite a few directories, including the main subdirectories of the root directory. It’s handy to know what’s contained in these directories; they’ll be the first place to look for specific files. Table 4.1 lists the main directories found in the root directory.

Table 4.1 The Main Subdirectories of the Root Directory
Directory Contents

bin Binary files
boot Information needed to boot the system
cdrom CD-ROM drive, if Linux supports your CD-ROM drive
dev Device drivers
etc Miscellaneous files, mostly used in system administration
home The home directory for users
lib Programming libraries
tmp Temporary storage of temporary files
usr Commands
var System definitions


NOTE:  Case counts in Linux across the board, as you’ll learn time and time again. (This is different from DOS, where case doesn’t matter.) If you tell Linux to look for a directory named BIN, the system won’t find this directory. However, if you tell Linux to look for bin, the system will find it.

The same goes for Linux commands—when we tell you to use the cd command, we mean cd, not Cd, CD, or cD. Again, this is different from DOS.


Depending on how you installed Linux, you may also have a directory called dos, dosc, or something similar, which contains the MS-DOS partition on your hard drive.


Previous Table of Contents Next