Linux Tutorial / File System Basics: Paths and Key Directories

The Linux file system can be understood as a single directory tree starting at /. A path identifies a location in that tree. Distinguishing an absolute path, which starts at /, from a relative path, which starts at your current working directory, helps you predict which file a command will affect. This lesson explains how to read paths and what common directories are generally used for.

One connected directory tree

Unlike the drive-letter layout familiar from Windows, Linux presents files and directories beneath one top-level directory called the root directory, written /. Another disk or file system is normally connected at a directory within this tree. That connection is called a mount. You cannot tell which physical disk holds a file merely by looking at the shape of its path.

/ and /root are different. The former is the starting point of the whole tree; the latter is commonly the root administrator account's home directory. Ordinary user home directories are often under /home/username, but account configuration can place them elsewhere.

Absolute and relative paths

An absolute path begins with /. For example, /etc/hosts refers to the same location regardless of your current directory. A relative path is interpreted from the current working directory. If that directory is /home/learner, then notes/todo.txt refers to /home/learner/notes/todo.txt.

Notation Meaning Example
/ Start of the file-system tree /etc/hosts
. Current directory ./script.sh
.. Parent directory ../notes
~ Expanded by the shell to the current user's home directory ~/notes

. and .. are directory entries used in relative paths. ~ is different: it is shell syntax, expanded before a command runs, rather than a literal file-system entry. In Bash, surrounding '~/notes' with single quotes prevents the tilde from expanding to your home directory.

Paths use / as a separator and generally distinguish uppercase from lowercase, so Notes and notes may be different names. Quote a path containing spaces, as in 'project notes', or escape the spaces so that the shell passes it as one argument.

What common directories are for

The table gives the usual purposes of locations you will encounter. Depending on the distribution and installation, a directory might be absent or linked to another location. It does not mean that every file always follows the pattern exactly.

Path Typical purpose
/home Home directories for ordinary users
/etc System and service configuration
/usr User-space programs and shared data
/var Data that changes during operation, including logs and caches
/tmp Temporary files
/dev Files representing devices
/proc, /sys Virtual file systems exposing kernel and system information
/boot Files needed for booting
/mnt, /media Places commonly used to mount additional storage

Do not casually edit or delete entries under /proc or /sys as if they were ordinary documents. Avoid keeping important data in /tmp for the long term because system policy may remove temporary files. Before changing configuration under /etc, understand the file's purpose and make a backup.

Practice reading a path

Read /home/learner/projects/report.txt from left to right. The initial / is the starting point; home, learner, and projects are directories along the way; and report.txt is the final component. A dot in the name does not prove the file's format or even that it exists.

If your current directory is /home/learner/projects, the relative path ../notes.txt refers to /home/learner/notes.txt in the parent directory. You still have to check whether that file exists. Interpreting a path and confirming its existence are separate tasks.

Before running a command, ask where you are and whether the path you entered is absolute or relative. This is especially important when moving or deleting files: a mistaken relative path can affect the wrong target. For a refresher on reading commands, see the terminal and shell basics lesson.

Official reference

The Filesystem Hierarchy Standard 3.0 describes general directory-layout conventions. Check your distribution and system configuration for the layout actually in use.

More in This Category
Linux apk Command: Manage Packages on Alpine Linux

Linux apk Command: Manage Packages on Alpine Linux

Learn how to manage Packages on Alpine Linux with the Linux apk command, including practical examples, key options, and important precautions.

Linux apt-get Command: Run APT Package Operations in Scripts

Linux apt-get Command: Run APT Package Operations in Scripts

Learn how to run APT Package Operations in Scripts with the Linux apt-get command, including practical examples, key options, and important precautions.

Linux Administration Memo: Essential Commands and System Checks

Linux Administration Memo: Essential Commands and System Checks

A compact Linux administration reference for checking system information, processes, storage, networking, users, permissions, services, and logs.

Linux Tutorial / Compare Files with diff and cmp

Linux Tutorial / Compare Files with diff and cmp

Use diff and cmp to compare two files, read unified diff output, and distinguish a detected difference from an actual command error.

Linux Tutorial / Hard Links vs. Symbolic Links in Linux: Differences and Examples

Linux Tutorial / Hard Links vs. Symbolic Links in Linux: Differences and Examples

Compare hard and symbolic links through inode and path behavior, then create both kinds of link and observe what happens when the original name changes.

Linux apt Command: Manage Packages on Debian and Ubuntu

Linux apt Command: Manage Packages on Debian and Ubuntu

Learn how to manage Packages on Debian and Ubuntu with the Linux apt command, including practical examples, key options, and important precautions.

Linux scp Command: Copy Files over SSH

Linux scp Command: Copy Files over SSH

Learn how to copy Files over SSH with the Linux scp command, including practical examples, key options, and important precautions.

Linux fold Command: Wrap Long Lines at a Fixed Width

Linux fold Command: Wrap Long Lines at a Fixed Width

Learn how to wrap Long Lines at a Fixed Width with the Linux fold command, including practical examples, key options, and important precautions.

Linux unzip Command: List and Extract ZIP Archives

Linux unzip Command: List and Extract ZIP Archives

Learn how to list and Extract ZIP Archives with the Linux unzip command, including practical examples, key options, and important precautions.

Linux ln Command: Create Hard Links and Symbolic Links

Linux ln Command: Create Hard Links and Symbolic Links

Learn how to create hard links and symbolic links with Linux ln, choose relative or absolute targets, replace links safely, and inspect link behavior.