The Linux File System

Common Types of Files
Files can contain various types of information. The following three types will become the most familiar to you:
 User data: Information that you create and update. The very simplest user data is plain text or numbers. More complicated user data files might have to be interpreted by another program to make sense. For instance, a spreadsheet file looks like gibberish if you look at it directly. To work with a spreadsheet, you have to start up the spreadsheet program and read in the spreadsheet file.

 System data: Information, often in plain text form, that is read and used by the Linux system—to keep track of which users are allowed on the system, for instance. As a system administrator, you are responsible for changing system data files. For instance, when you create a new user, you modify the file /etc/passwd, which contains the user information. Ordinary users of the system are usually not concerned with system data files, except for their private startup files.

 Executable files: These files contain instructions that your computer can perform. This set of instructions is often called a program. When you tell the computer to perform them, you're telling it to execute the instructions given to it. To human eyes, executable files contain meaningless gibberish—obviously your computer doesn't think the way you do! Creating or modifying executable files takes special tools. You learn how to use these programming tools in Part V, "Linux for Programmers."



Filenames
Linux allows filenames to be up to 256 characters long. These characters can be lower- and uppercase letters, numbers, and other characters, usually the dash (-), the underscore (_), and the dot (.).
They can't include reserved metacharacters such as the asterisk, question mark, backslash, and space, because these all have meaning to the shell.

Directories
Linux, like many other operating systems, organizes files in directories. These directories contain files and possibly other directories in turn, and so on.


The Root Directory
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. From the root directory, the entire structure of directory upon directory springs and. This is called a tree structure because, from the single root directory, directories and subdirectories branch off like tree limbs.


How Directories Are Named
Directories are named just like files, and they can contain upper- and lowercase letters, numbers, and characters such as -, ., and _.
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 can't 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 item—namely, bin. When you see usr/bin/grep, you know that both usr and bin must be directories, but again, you can't be sure about grep. The ls program shows the contents of the directories. The root directory is shown simply by the symbol / rather than mentioned by name. It's very easy to tell when / is used to separate directories and when it's 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 can't be a subdirectory.


The Home Directory
Linux provides each user with his or her own directory, called the home directory. Within this home directory, users can store their own files and create subdirectories. Users generally have complete control over what's found in their home directories. Because there are usually no Linux system files or files belonging to other users in your home directory, you can create, name, move, and delete files and directories as you see fit.
The location of a user's home directory is specified by Linux and can't be changed by the user. This is both to keep things tidy and to preserve system security.


Navigating the Linux File System
Fortunately, navigating the Linux file system is simple.