The Filesystem

To make use of any Linux system, you need to be comfortable with Linux files and directories (a.k.a. folders). In a “windows and icons” system, the files and directories are obvious on screen. With a command-line system like the Linux shell, the same files and directories are still present but are not constantly visible, so at times you must remember which directory you are “in” and how it relates to other directories. You’ll use shell commands like cd and pwd to “move” between directories and keep track of where you are.

Let’s cover some terminology. As we’ve said, Linux files are collected into directories. The directories form a hierarchy, or tree, as in Figure 1-3: one directory may contain other directories, called subdirectories, which may themselves contain other files and subdirectories, and so on, into infinity. The topmost directory is called the root directory and is denoted by a slash (/).[3]

A Linux filesystem (partial). The root folder is at the top. The “dan” folder’s full path is /home/dan.

Figure 1-3. A Linux filesystem (partial). The root folder is at the top. The “dan” folder’s full path is /home/dan.

We refer to files and directories using a “names and slashes” syntax called a path. For instance, this path:

/one/two/three/four

refers to the root directory /, which contains a directory called one, which contains a directory two, which contains a directory three, which contains a final file or directory, four. If a path begins with the root directory, it’s ...

Get Linux Pocket Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.