1.2 Filesystem and Paths
The Linux filesystem is a tree that grows from /. Disks, configuration, user directories, logs, programs, and mounted storage all live somewhere under this tree.
Common directories
| Path | How to think about it |
|---|---|
/ | Root, the starting point of the whole filesystem tree |
/home | Home directories for normal users |
/root | The root user's home directory, not the same as / |
/etc | System and service configuration |
/var | Changing data such as logs, caches, and queues |
/tmp | Temporary files that may disappear after reboot or cleanup |
/usr | Many user-level programs and libraries |
/bin, /sbin | Basic commands and system commands |
/opt | Some third-party software installs here |
You do not need to memorize everything at once. Start with this: user files live around /home, configuration around /etc, logs around /var/log.
Absolute and relative paths
A path starting with / is absolute:
/var/log/nginx/access.logIt starts from the root directory and does not depend on your current location.
A path that does not start with / is relative:
logs/app.log
../notes/today.mdIt is resolved from the current working directory.
Four special path forms
~: the current user's home directory, such as/home/leaf..: the current directory...: the parent directory.-: the previous directory, commonly used withcd -.
If you can explain these four symbols, many path problems become much easier.
What is a mount point?
In Linux, disks, USB drives, network storage, and container volumes can be attached to a directory. That directory is called a mount point. For example, a data disk might be mounted at /data, and then /data/uploads refers to files on that disk.
These commands help inspect disks and mounts:
df -h
mount
lsblkdf -h is common for disk space; lsblk is common for block-device structure.
A good path habit
Before entering or changing an unfamiliar directory, run:
pwd
lsBefore deleting, moving, or changing permissions, confirm that the path is truly the path you intend. Many production incidents happen because the command syntax was correct, but the location was wrong.