-->
Previous | Table of Contents | Next |
Linux, like many other computer systems, organizes files into directories. You can think of directories as file folders and their contents as the files. However, there is one absolutely crucial difference between the Linux file system and an office filing system. In the office, file folders usually dont contain other file folders. In Linux, file folders can contain other file folders. In fact, there is no Linux filing cabinetjust a huge file folder that holds some files and other folders. These folders contain files and possibly other folders in turn, and so on.
Imagine a scenario in which you have a directory, A, that contains another directory, B. Directory B is then a subdirectory of directory A, and directory A is the parent directory of directory B. You will see these terms often, both in this book and elsewhere.
With Linux, there is no real limit to the number of directories and subdirectories you have on your system. The same applies for the number of files. As long as there is space on the hard drive, Linux will be able to save files and directories. A directory can have an unlimited number of subdirectories, and they themselves can have an unlimited number of subdirectories, and so on. Each directory and subdirectory can have an unlimited number of files. The key to understanding the way Linux organizes files and directories is recognizing that there is only one top-level directory, from which all others are subdirectories.
In Linux, the directory that holds all the other directories is called the root directory. This is the ultimate parent directory; every other directory is some level of subdirectory. The root directory has a special symbol, /, which is used to show it is the top level. Youll see how all other subdirectories branch off from the root directory in the next few sections.
From the root directory, the whole structure of directory upon directory springs and grows like some electronic elm tree. This is called a tree structure because, from the single root directory, directories and subdirectories branch off like tree limbs. Youll also hear this called a hierarchical directory structure because there is a hierarchy of levels of directories, with the highest level as the root directory.
Just a quick word about file systems. Youll see the words file system used throughout this book. Thats because UNIX has always referred to directory structures as file systems. Theres quite a bit of history behind it, but all the directories on your Linux system are your systems file system. Thats where Linux stores the files.
Directories are named just like files, and they can contain upper- and lowercase letters, numbers, and characters such as -, ., and _. Essentially, to Linux a directory name is a file because it makes no distinction between the two. You can name directories the same, as long as they are not in the same parent directory (to prevent having two directories called data under the same parent directory), but you can have any number of directories called data in your file system as long as they dont share parents.
The slash (/) character is used to show files or directories within other directories. For instance, usr/bin means that bin is found in the usr directory. Note that you cant tell from this example whether bin is a file or a directory, although you know that usr must be a directory because it holds another itemnamely, the directory bin. When you see usr/bin/grep, you know that both usr and bin must be directories, but again, you cant be sure about
grep. The ls program often shows directories followed by a backslash (sometimes this requires the -F option)for example, to show that fido is a directory, ls shows it as fido/. This notation implies that you could have, for instance, fido/file; therefore, fido must be a directory.As mentioned earlier, the root directory is shown simply by the symbol / rather than mentioned by name. Its very easy to tell when / is used to separate directories and when its used to signify the root directory. If / has no name before it, it stands for the root directory. For example, /usr means that the usr subdirectory is found in the root directory, and /usr/bin means that bin is found in the usr directory and that usr is a subdirectory of the root directory. Remember, by definition the root directory cannot be a subdirectory.
Previous | Table of Contents | Next |