EP6: Linux Filesystem Structure

In this episode, we explore the basic structure of the Linux filesystem, what each top-level folder means, and why it's important — especially for the RHCSA exam.


📁 What is the Linux Filesystem?

Linux organizes everything — files, folders, devices — into a single root tree that starts from / (root directory).

It’s like your C:\ drive in Windows, but without letters (D:, E:, etc).


🗂️ Top-Level Directories You Must Know

Here are the most important directories in RHCSA and daily Linux use:

Directory

Purpose

RHCSA Relevance

Why is it called that?

/

Root of the entire filesystem

⭐️ Must know

Root = the starting point (like tree root)

/etc

Configuration files for system and services

✅ High

Et cetera – old Unix naming for system config stuff

/home

User home directories (/home/user1, etc.)

✅ High

Home = personal space for each user

/var

Variable files – logs, mail, printer queues, web data

✅ High

Variable = content that changes often

/bin

Essential user commands (ls, cp, etc.)

⭐️ RHCSA shell

Bin = Binary (compiled executables)

/sbin

System binaries (reboot, iptables, etc.)

⭐️ Admin tasks

Superuser binaries

/usr

User-installed apps and libraries

Medium

Unix System Resources (not just user)

/boot

Bootloader files – kernel, GRUB

✅ RHCSA boot

Boot = files needed to boot the OS

/dev

Device files (disk, USB, etc.)

✅ RHCSA storage

Device – hardware seen as files

/proc

Virtual files representing system state (CPU, memory)

Optional

Process – runtime system processes

/tmp

Temporary files – auto-deleted on reboot

Optional

Tmp = Temporary

/root

Home directory for root user

RHCSA root login

Root = home of the root superuser

/lib

Essential shared libraries for system booting

Medium

Lib = Library of shared functions

/media

Mount points for external media (USB, CD)

Optional

Media = plug-in media devices

/mnt

Temporary mount points

Optional

MNT = Mount (temporary disks)

/opt

Optional or third-party software

Low

Optional = extra, custom apps

/srv

Data for services like FTP, HTTP

Rare

Srv = Service content


📚 Key Directories Explained Simply

🛠️ /etc – Configuration Center

Contains all major config files for services and system

Examples:

/etc/hostname       # System name
/etc/hosts          # Manual DNS entries
/etc/ssh/sshd_config # SSH settings
/etc/fstab          # Mount points
/etc/passwd         # User account list

📌 RHCSA Tip: You'll edit files in /etc often (firewalld, sshd, networking, etc.)


🏠 /home – User Data

Where each regular user stores their files

Examples:

/home/rama         
/home/joko         

📌 RHCSA Tip: Know how to manage /home permissions and backups


🧾 /var – Variable Data

Stores data that changes over time

Examples:

/var/log/           # System logs (check with `journalctl`)
/var/spool/         # Print jobs or mail
/var/www/           # Web server root (Apache)
/var/lib/           # App databases (like yum, firewalld)

📌 RHCSA Tip: Logs are in /var/log/ — useful for troubleshooting


🔍 View Filesystem Layout in CLI

Show all mounted filesystems:

df -h

View detailed hierarchy:

tree -L 1 /

(Install tree if not available: sudo dnf install tree)


Bonus: to get location configuration file for 3rd party package

"When I install a 3rd-party package like nginx, where are its config files located?"

Here are 3 reliable ways to find it — just like you mentioned — with examples and best practices.


🔎 1. Check the Official Documentation

Most 3rd-party tools (like Nginx, Apache, PostgreSQL, etc.) document the default config file location clearly.

For Nginx:

Best Practice:

  • Use vendor docs when installing from source or non-default repos.

📖 2. Use man (Manual Page)

The man page of the service usually mentions config file locations at the top or near the bottom.

Example:

man nginx

Then:

  • Press / to search

  • Type conf or configuration

  • Example output:

    The default configuration file is /etc/nginx/nginx.conf
    

✅ Works for: nginx, sshd, httpd, postfix, etc.


🔍 3. Use Linux File Search Tools

A. rpm -ql (for RPM-based systems like RHEL/Rocky)

Lists all files installed by a package:

rpm -ql nginx

Output sample:

/etc/nginx/nginx.conf
/etc/nginx/conf.d/
/usr/sbin/nginx
...

B. dnf repoquery --list (modern way)

dnf repoquery --list nginx

C. Use find or locate commands:

sudo find /etc -name '*nginx*'

Or faster (after updating database):

sudo updatedb
locate nginx.conf

✅ Best for quick searches if unsure where files are stored.


📦 Bonus: Check Package Info via rpm

To see package ownership of a config file:

rpm -qf /etc/nginx/nginx.conf

To see a short description:

rpm -qi nginx
Updated on