Skip to content

Beginner · Linux and the shell · topic 2 of 57 · 30 min

The filesystem hierarchy and paths

Explanation

Linux has one tree of folders that starts at / (the root). Each top folder has a job: /etc holds settings, /var holds changing data like logs, /home holds users' files. An absolute path starts with /; a relative path starts from the folder you are in.

One tree, not drive letters

Windows shows disks as C:, D: and so on. Linux has a single tree of directories (folders) that starts at / , called the root directory. Every disk, USB stick or network share is attached somewhere inside this tree; attaching it is called mounting. So /home might live on one disk and /var on another, but you see one tree.

Think of it like this: Think of a big office building. / is the main gate. Each floor has a fixed purpose: accounts on one floor, HR on another, the store room in the basement. You can find things in any office of the company because every building follows the same plan. Linux servers follow the same plan too.

The important directories

DirectoryWhat lives there
/etcSystem settings (config files): /etc/passwd, /etc/fstab, /etc/ssh/sshd_config
/varData that changes: logs in /var/log, web pages in /var/www, databases in /var/lib
/homeHome directories of normal users, like /home/asha
/rootHome directory of the root (admin) user. Not the same as /
/usrInstalled programs and libraries: /usr/bin, /usr/lib, /usr/share
/bin, /sbin, /libOn RHEL these are links into /usr (for example /bin points to /usr/bin)
/tmpTemporary files any user can write; cleaned up regularly
/bootThe kernel, the initramfs and the GRUB boot loader files
/devDevice files: disks such as /dev/sda or /dev/vda, and /dev/null
/proc, /sysVirtual files the kernel creates to show live information
/runRuntime data that disappears at reboot (PID files, sockets)
/opt, /srvOptional third-party software; data served by this system

This layout comes from the Filesystem Hierarchy Standard (FHS). The man page hier(7) describes it on your own machine: run man hier.

Absolute and relative paths

A path is the address of a file. An absolute path starts with / and works from anywhere: /etc/hosts. A relative path does not start with / and is read from your current working directory (the folder you are in now). If you are in /etc, the relative path ssh/sshd_config means /etc/ssh/sshd_config.

  • . (one dot) means "this directory".
  • .. (two dots) means "the parent directory", one level up.
  • ~ (tilde) means your home directory, for example /home/asha.
  • - with cd means "the directory I was in before".
bash
$ pwd
/home/asha
$ cd /etc/ssh
$ pwd
/etc/ssh
$ cd ../sysconfig
$ pwd
/etc/sysconfig
$ cd ~
$ pwd
/home/asha
pwd prints the working directory. cd changes it. ../sysconfig goes up to /etc, then into sysconfig.

Everything is a file

Linux shows many things as files: disks (/dev/sda), the random number source (/dev/urandom), and live kernel data (/proc/cpuinfo). That is why you can read the CPU details with cat /proc/cpuinfo, or throw unwanted output into /dev/null, a file that swallows everything written to it.

Common mistakes

  • Mixing up / (the root of the tree) and /root (the root user's home folder).
  • Using a relative path in a script or cron job. The script may run from a different directory, so the file is not found. Use absolute paths in scripts.
  • Typing C:\ style paths or backslashes. Linux uses forward slashes, and names are case-sensitive: Report.txt and report.txt are two different files.
Tip: When you meet a new server, run ls / and df -h first. In ten seconds you know the layout and which directories are on which disks.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

The filesystem hierarchy and paths · 1/7

/

Linux has one tree of folders, starting at slash, the root directory.

Prefer a video by a teacher? Find free videos on “linux filesystem hierarchy explained etc var usr” on YouTube ↗

In real life: Finding logs on a college lab server

A college in Pune runs its exam portal on a RHEL server. During the exam the portal is slow. The lab assistant does not know the app, but she knows the hierarchy: settings are in /etc, logs are in /var/log, and the web content is in /var/www. In two minutes she finds /var/log/httpd/error_log full of "too many open files" lines and calls the right person.

bash
$ ls /var/log/httpd/
access_log  error_log
$ tail -n 2 /var/log/httpd/error_log
[Mon Oct 19 10:02:11 2026] [error] (24)Too many open files: AH00169: ...
[Mon Oct 19 10:02:12 2026] [error] (24)Too many open files: AH00169: ...

Practice (0/3 done)

Task 1 · Question

Where would you look first for the settings file of the SSH server?

Task 2 · Code · Python

Write resolve(cwd, path) that returns the absolute path the shell would use. cwd is an absolute directory like "/etc". If path starts with "/" it is already absolute. Otherwise join it to cwd. Then handle "." (stay) and ".." (go up one, but never above "/"). Return "/" for the root. Do not use the os module; split on "/".

Task 3 · Practice

On your lab VM, explore the tree and write one line about what you found in each of: /etc, /var/log, /home, /boot, /dev, /proc.

Quick quiz

Question 1

1.Which directory holds log files?

Question 2

2.You are in /etc. Which absolute path does the relative path ../home/asha mean?

Question 3

3.What is /root?

Question 4

4.Which path is absolute?

Question 5

5.Why use absolute paths in scripts?

Read more (free)

Before this, learn

This topic builds on these. If something here feels new, open them first.

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

Which directory holds log files?

Answer: /var/log

Changing data such as logs lives under /var; logs are in /var/log.

You are in /etc. Which absolute path does the relative path ../home/asha mean?

Answer: /home/asha

.. takes you from /etc up to /, then into home/asha.

What is /root?

Answer: The home directory of the root user

The top of the tree is /. /root is root's home directory.

Which path is absolute?

Answer: /etc/hosts

Only paths that start with / are absolute.

Why use absolute paths in scripts?

Answer: The script may run from a different working directory

A relative path depends on the current directory, which may be different when cron or another user runs the script.

Which folder holds log files on a typical Linux server?Related

Answer: /var/log

/var/log holds system and many application logs.

From The Linux filesystem and everyday commands

Which attribute holds the address of a link?Related

Answer: href

href (hypertext reference) is where the link goes. src is used by images and media.

From Links: connecting pages

Which file holds Linux password hashes?Related

Answer: /etc/shadow

/etc/shadow holds the hashes and is readable only by root (and the shadow group).

From Linux security basics

An absolute badge flies to the corner of the whole page. What is missing?Related

Answer: position: relative on the card

Without a positioned ancestor, absolute elements use the page as their reference.

From Positioning and stacking

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 4 more topics in “Linux and the shell” before its exam: Shell basics and getting help, Working with files: ls, cp, mv, rm, links and find, Reading text: grep, less, pipes and redirection, Editing files with vim.
  2. Module 1 exam: Linux and the shell · 13 questions · 20 min, without help. 6 topics of this module still to finish first.
  3. Then the next module, Permissions, users and sudo. 57 topics left in the course before the final exam.

← Previous: What Linux and Red Hat Enterprise Linux are