The Linux file system uses a standard tree structure to organize directories and files. The top level of the directory tree is called the root directory and is indicated by a slash (/). All other files and directories branch out from the root. There are essential directories that exist as subdirectories of the root directory. The following table describes the contents of some of these subdirectories.
Directory... |
Contains... |
/ (root) |
all files or subdirectories on the system |
/bin |
binaries or executable programs for the Linux system |
/dev |
device files which access system devices and resources, such as modems, memory, and disk drives |
/usr |
user-oriented directories such as games and manual pages |
/usr/sbin |
system administration files, most of which are accessible only to the root user |
/sbin |
system files that Linux usually runs automatically |
/home |
files and directories created by users. Users can create or delete files as necessary in this directory because it does not contain system files or files from other users. |
/etc |
system configuration files |
A directory that contains subdirectories is called a parent directory. For example, the root directory (/) is the parent directory of the home subdirectory. Linux uses a slash (/) to indicate files and directories within a directory. For example, etc/bin means that bin is located within the etc directory.
You can switch between directories at the command line. Although you can move anywhere in the file system, users spend most of their time in the /home directory. Each user has a /home directory and can manage those files and directories. Usually Linux organizes the /home directory according to your login name e.g. /home/Mabel, where "Mabel" is a user on the Linux system.
You can list the contents of a directory to check that the file or subdirectory that you want to access, exists within it.
Relative and absolute path names
The shell requires a path name to locate the file, directory, or subdirectory that you want to access. You can use relative or absolute path names. When you use a relative path name, the shell interprets the command in relation to your working directory. Using an absolute path name, tells the shell to interpret the command starting at the root directory. For example, using the following relative path name, the More command lets you view the file called file1 that exists in the subdirectory, subdir1, of your working directory.
Mabel~:$ more subdir1/file1
However, if the file exists in a directory that is outside your working directory, you must use the absolute path name to locate the file. For example, using the following absolute path name, the More command lets you view the file called file2, that exists in the subdirectory, subdir2, of the directory /usr. The directory usr, is one of the essential directories that exists as a subdirectory of the root directory (/).
Mabel~:$ more /usr/subdir2/file2
Linux files
You can use characters such as periods (.), hyphens (-), and underscores (_) in filenames. Characters can be uppercase or lowercase. Linux designates some files as hidden files. Hidden files consist primarily of configuration files and have a dot (.) as the first character of their filename. Linux does not automatically list hidden files.
You cannot have two files with identical filenames in the same directory, however, you can have identical filenames in different directories.