
This lesson explains how Linux arranges files and directories and how to move with speed and safety. It covers absolute and relative paths, the Filesystem Hierarchy Standard, common directories, symlinks, mounts, and tools to check disk usage.
FHS stands for Filesystem Hierarchy Standard. It describes the general layout of directories on Unix like systems. Not every distribution follows it exactly, but the big ideas are stable across Linux.
Prerequisites
Absolute paths and relative paths
- Absolute path: starts at
/and names every directory down to the target. Example:/etc/ssh/sshd_config. - Relative path: starts from the current working directory. Example: if the current directory is
/etc, thenssh/sshd_configrefers to/etc/ssh/sshd_config.
Useful commands:
pwd # print current working directory
cd /etc # go to an absolute path
cd ssh # relative path from /etc to /etc/ssh
cd - # go back to the previous directory
cd ~ # go to the home directory
cd ~/projects # absolute path with tilde expansionThink of / as the root of a single large tree. Every file lives somewhere under /. Even other disks and USB drives get attached at a directory called a mount point.
Quick navigation cheatsheet
ls -la # long view, show hidden files (names starting with .)
ls -lah # add human readable sizes
ls -ld */ # list only subdirectories
# jump to important places
cd / # filesystem root
cd /etc # system configuration
cd /var/log # logs
cd /home/$USER # home directoryHidden files and directories begin with a dot. Use ls -A to include them.
Filesystem Hierarchy tour

The most common top level directories and what they contain:
/root of the filesystem/bin,/sbin,/usr/bin,/usr/sbincommand binaries and system tools. Many modern systems place most tools under/usrand provide compatibility links./lib,/lib64,/usr/libshared libraries for programs/etcsystem configuration files in plain text/varvariable data such as logs, caches, spools, and databases/homeuser home directories/roothome directory for the superuser/tmptemporary files that may be cleaned at boot or by timers/runvolatile runtime data such as PID files and sockets/optoptional add on software installed outside the package manager/srvdata for services served by the system, such as web or FTP content/mediaand/mntmount points for removable media or manual mounts/devdevice files that represent hardware and kernel interfaces/procand/sysvirtual filesystems that expose kernel and device information
Quick inspection:
sudo ls -l / /bin /etc /home /var | sed -n '1,80p'
ls -l /usr/bin | head
ls -l /dev | headConfiguration files under /etc affect the whole system. Make a copy before changes and prefer using the package manager or documented tools when possible.
Inspecting files and directories
# show details including permissions, owner, size, and time
ls -l
# human readable sizes and classification marks
ls -lahF
# what type of thing is this
file /etc/hosts
# metadata with inodes and links
stat /etc/hosts
# follow symlinks and print the real path
readlink -f /bin/sh
realpath /bin/shNotes:
filereads magic signatures and reports the file type.statshows the inode number. Files with the same inode on the same filesystem are hard links to the same data.
Safe movement and deletion
# move and copy with prompts for existing targets
cp -i source.txt dest.txt
mv -i oldname newname
# preview what a wildcard expands to before deleting
printf '%s\n' *.log
# delete interactively or by explicit path
rm -i notes.txt
rm -- -weird-name
# move to trash instead of permanent delete (optional)
# Ubuntu: sudo apt install trash-cli
trash-put notes.txtAvoid rm -rf / and avoid running rm -rf * in directories that contain mounts or important data. Always check pwd and run ls first.
Finding files and folders
find walks the directory tree and applies tests.
# by name and type
target=$HOME
find "$target" -type f -name "*.log" -maxdepth 3
# by size and modification time
find /var/log -type f -size +50M -mtime -7 -printf '%p %s bytes\n'
# run a command on matches (use -print0 with xargs -0 for safety)
find . -type f -name "*.tmp" -print0 | xargs -0 rm -v
# case insensitive name search
find /etc -type f -iname "*ssh*"
# stop at filesystem boundaries
sudo find / -xdev -type f -size +1G 2>/dev/nulllocate searches a prebuilt index. It is very fast but may be out of date until the index refreshes.
# install and initialize if missing
sudo apt install -y mlocate || sudo dnf install -y mlocate
sudo updatedb
locate sshd_config | headSymlinks and hard links
- Symbolic link (symlink): a pointer to another path. It can cross filesystems. If the target is removed, the link breaks.
- Hard link: another name for the same inode and data on the same filesystem.
Examples:
# prepare a demo file
mkdir -p ~/playground/day3 && cd ~/playground/day3
echo "demo" > original.txt
# make a symlink and a hard link
ln -s original.txt link-sym.txt
ln original.txt link-hard.txt
# compare inodes (first column)
ls -li original.txt link-sym.txt link-hard.txt
# remove the original and see what survives
rm original.txt
ls -li
# the symlink shows a broken target, the hard link still contains the dataSystem tools often use symlinks. For example /bin/sh usually points to dash or bash through a chain of links. Package managers also use symlinks to switch versions.
Mount points and virtual filesystems
Linux attaches filesystems under existing directories. The directory is called a mount point.
# view block devices and mount points
lsblk -f
findmnt -t ext4,xfs,vfat
# current mounts
mount | head
# fstab entries for persistent mounts
grep -v '^#' /etc/fstab | sed '/^$/d'Notes:
/procand/sysare virtual filesystems provided by the kernel. They do not occupy disk space like normal files.- Removable drives often appear under
/media/$USER/NAMEwhen auto mounted by the desktop.
An incorrect /etc/fstab entry can prevent boot. Make a backup first and test manual mounts before writing to fstab.
Checking space usage
# free space per filesystem with types
df -hT
# disk usage in the current directory, sorted by size
du -sh * | sort -h
# top space consumers two levels down
du -h --max-depth=2 /var | sort -h | tail -20Tip: run heavy du commands with sudo when permission denied appears, or use -x to stay on one filesystem.
Practical lab
The lab builds muscle memory for safe navigation and inspection.
- Create a playground and explore hidden files.
mkdir -p ~/playground/day3 && cd ~/playground/day3
printf "alpha\n" > a.txt
printf "beta\n" > b.txt
mkdir notes docs
printf "hidden\n" > .secret
ls -lah- Practice absolute and relative moves, then check where you are.
cd ~/playground/day3/docs
pwd
cd ..
pwd
cd /etc
pwd
cd -- Inspect types and metadata.
file a.txt
stat a.txt- Create links and study inodes.
ln -s a.txt a-symlink
ln a.txt a-hard
ls -li a*- Find candidates for cleanup and remove them safely.
find . -type f -name "*.tmp" -print
# if the list looks correct
echo "ok" && find . -type f -name "*.tmp" -delete- Measure usage.
df -hT | head
du -sh ~/* | sort -h | tail -10Common pitfalls
- Confusing absolute and relative paths. Use
pwdbefore running risky commands. - Deleting through a symlink and removing the target unexpectedly. Inspect with
ls -lorreadlink -ffirst. - Running
rm -rf *in the wrong directory. Preview withprintf '%s\n' *and use-i. - Editing
/etcfiles without backups. Copy to.bakfirst. - Forgetting that
/procand/sysare virtual. Do not try to free space there.
Up next: [Day 4 - Viewing and Editing Files in the Terminal])(./day-3-navigating-the-filesystem-and-fhs)
Day 4 focuses on viewing and editing files in the terminal.