Red Hat System Administration I · RH124

Chapter 6

Navigating the File-System Hierarchy
FHS layout · Absolute & relative paths · Moving, copying, and finding files
CIS126RH — Mesa Community College

Chapter Objective

Describe the purpose of key directories in the Linux filesystem hierarchy, and navigate, create, copy, move, and locate files and directories from the command line.

Key Commands

  • pwd
  • cd
  • ls
  • file
  • mkdir
  • cp
  • mv
  • rm
  • ln
  • find

The Filesystem Hierarchy Standard

Linux organizes all files into a single tree, starting at the root directory (/). Every file and directory on the system — regardless of which physical disk or partition it lives on — has a location somewhere under /. Red Hat Enterprise Linux follows the Filesystem Hierarchy Standard (FHS), a convention shared across most Linux distributions for what belongs where.

Why It Matters — Knowing the FHS means you can predict where to find a configuration file, a log, or a binary on any RHEL system — even one you've never logged into before.

Key Top-Level Directories

DirectoryPurpose
/The root directory; top of the entire tree
/bin, /usr/binEssential user command binaries
/sbin, /usr/sbinSystem administration binaries
/etcSystem-wide configuration files
/varVariable data: logs, spool files, caches
/homeRegular users' home directories
/rootThe root user's home directory
/optOptional third-party software packages
/tmpTemporary files, cleared periodically
/devDevice files representing hardware
/proc, /sysVirtual filesystems exposing kernel and process information
/mnt, /mediaMount points for temporary or removable filesystems
Tip — man hier — Run man hier for the full, authoritative description of the Filesystem Hierarchy Standard directly on the system.

Navigating Directories

Every process — including your shell — has a current working directory. Paths you type are interpreted relative to it, unless they start with /.

# Print the current working directory
pwd

# Change to an absolute path — always starts from root
cd /etc/ssh

# Change to a relative path — starts from where you are now
cd ../ssh

# Shortcuts
cd ~        # your home directory
cd          # also your home directory (no argument)
cd -        # the previous directory
cd ..       # the parent directory
cd .        # the current directory (rarely useful with cd itself)
Note — . and .. Are Everywhere — Every directory contains two special entries: . refers to itself, and .. refers to its parent. Many commands, not just cd, accept these.

Listing and Inspecting Files

# Basic listing of the current directory
ls

# Long format: permissions, owner, size, modification time
ls -l

# Include hidden files (those starting with a dot)
ls -a

# Combine common options
ls -la

# Human-readable file sizes (K, M, G instead of raw bytes)
ls -lh

# List a specific directory without changing into it
ls -l /etc/ssh

Identifying File Types

# Determine what kind of content a file actually contains
file /etc/passwd
file /usr/bin/bash
file /etc/ssh/ssh_host_ed25519_key
Tip — Don't Trust the Extension — Linux doesn't rely on file extensions the way some other operating systems do. A file named report.txt could actually contain binary data. Use file when you're not sure what you're looking at.

Creating, Copying, Moving, Removing

# Create a new empty directory
mkdir project

# Create nested directories in one step
mkdir -p project/src/lib

# Create an empty file, or update its timestamp if it exists
touch notes.txt

# Copy a file
cp notes.txt notes-backup.txt

# Copy a directory and its contents recursively
cp -r project/ project-backup/

# Move or rename a file (mv does both)
mv notes-backup.txt archive/notes-2026.txt

# Remove a file
rm notes.txt

# Remove a directory and everything inside it
rm -r project-backup/

# Prompt before each removal — a safer habit for destructive commands
rm -ri project-backup/
Warning — rm Has No Undo — There is no recycle bin at the command line. rm -r on the wrong directory — especially combined with -f to force it — can destroy data permanently. Double-check the path before pressing Enter.

Hard Links and Symbolic Links

A link lets one or more names refer to the same underlying data. Linux supports two kinds.

TypeBehavior
Hard linkA second directory entry pointing to the same inode; both names are equally "real." Cannot cross filesystems or point to directories.
Symbolic link (symlink)A special file that stores a path to another file. Can cross filesystems and point to directories. Breaks if the target is removed.
# Create a hard link
ln original.txt hardlink.txt

# Create a symbolic link
ln -s /etc/ssh/sshd_config sshd_config_link

# Symlinks are visually distinguishable in a long listing (-> target)
ls -l sshd_config_link
Exam Note — Know the practical difference: deleting the original file breaks a symlink (it becomes "dangling"), but a hard link keeps the data intact until every hard link to it is removed.

Finding Files

# Find files by name under a starting directory
find /etc -name "*.conf"

# Case-insensitive name search
find /home -iname "*report*"

# Find only regular files, or only directories
find /var/log -type f
find /var/log -type d

# Find files modified in the last 1 day
find /etc -mtime -1

# Find files larger than 100 megabytes
find / -size +100M
Tip — find vs. locatefind searches the live filesystem in real time, so results are always current but the search can be slow on large trees. locate (if installed) searches a prebuilt index — much faster, but only as current as its last database update.

Key Terms for Chapter 6

Filesystem Hierarchy Standard (FHS)
The convention defining the purpose of standard top-level Linux directories
root directory
The top of the filesystem tree, written as /
working directory
The directory a process (such as your shell) is currently "in"
absolute path
A path that starts from the root directory /
relative path
A path interpreted starting from the current working directory
inode
The data structure storing a file's metadata and location on disk, separate from its name
hard link
A directory entry pointing to the same inode as another name; cannot cross filesystems
symbolic link (symlink)
A special file that stores a path to another file or directory; can cross filesystems
find
Command that searches the live filesystem for files matching given criteria

Review Questions

  1. Where does RHEL store system-wide configuration files, and where does it store variable data like logs?
  2. What is the difference between cd .. and cd -?
  3. You see a file named data.txt but suspect it isn't actually plain text. What command would confirm what it really is?
  4. What option to mkdir lets you create a directory and any missing parent directories in one command?
  5. Why is rm -r considered dangerous, and what option can make it safer to run interactively?
  6. What happens to a symbolic link if the file it points to is deleted? What about a hard link in the same situation?
  7. Write a find command that searches /var/log for regular files larger than 50 megabytes.
1 / 12