The Filesystem

To make use of any Linux system, you need to be comfortable with Linux files and their layout. Every Linux file is contained in a collection called a directory. Directories are like folders on Windows and Macintosh systems. Directories form a hierarchy, or tree: 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 (/).[5]

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 called an absolute path, and if not, it’s a relative path. More on this in a moment.

Whenever you are running a shell, that shell is “in” some directory (in an abstract sense). More technically, your shell has a current working directory, and when you run commands in that shell, they operate relative (there’s that word again) to the directory. More specifically, if you refer to a relative file path in that shell, it is relative to your current working directory. For example, if your shell is “in” the directory /one/two/three, and you run a command that refers to a file myfile, then it’s really /one/two/three/myfile. Likewise, ...

Get Linux Pocket Guide 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.