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 sftp Command: Transfer Files Securely over SSH

Linux sftp Command: Transfer Files Securely over SSH

Learn how to use the Linux sftp command to transfer and manage files securely through an SSH connection, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux ethtool Command: Inspect Network Link and Driver Settings

Linux ethtool Command: Inspect Network Link and Driver Settings

Learn how to inspect Network Link and Driver Settings with the Linux ethtool command, including practical examples, key options, and important precautions.

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Learn what ls, file, stat, and readlink each reveal about a Linux file, including type, size, timestamps, and symbolic-link targets.

Linux wc Command: Count Lines, Words, Characters, and Bytes

Linux wc Command: Count Lines, Words, Characters, and Bytes

Learn how to use the Linux wc command to count lines, words, characters, and bytes in files or standard input, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux getent Command: Query Users, Groups, and Other NSS Databases

Linux getent Command: Query Users, Groups, and Other NSS Databases

Learn how to query Users, Groups, and Other NSS Databases with the Linux getent command, including practical examples, key options, and important precautions.

Linux nmap Command: Scan Authorized Hosts and Ports

Linux nmap Command: Scan Authorized Hosts and Ports

Learn how to scan Authorized Hosts and Ports with the Linux nmap command, including practical examples, key options, and important precautions.

Linux diff Command: Compare Text Files and Directories

Linux diff Command: Compare Text Files and Directories

Learn how Linux diff compares text files and directories, produces unified patches, ignores selected whitespace changes, and reports differences through exit status.

Linux nc Command: Test TCP and UDP Connections

Linux nc Command: Test TCP and UDP Connections

Learn how to test TCP and UDP Connections with the Linux nc command, including practical examples, key options, and important precautions.

Linux bg Command: Resume a Shell Job in the Background

Linux bg Command: Resume a Shell Job in the Background

Learn how to resume a Shell Job in the Background with the Linux bg command, including practical examples, key options, and important precautions.

Linux kill Command: Send a Signal to a Process ID

Linux kill Command: Send a Signal to a Process ID

Learn how to send a Signal to a Process ID with the Linux kill command, including practical examples, key options, and important precautions.