Skip to content
Laviyx Learn

Try

Linux and Bash course menu

The Linux File System Explained: /etc, /var, /home and Paths

Understand the Linux directory structure: the root folder, /home, /etc, /var, /usr, /tmp and more, absolute and relative paths, hidden files, and why everything is a file.

Beginner7 min readUpdated
On this page

Windows has drives such as C:\. Linux has one tree, starting at a single folder called the root, written /. Everything sits somewhere below it, even other disks and USB sticks.

Terminal
ls /
Output
bin
bin.usr-is-merged
boot
dev
etc
home
imagegeneration
lib
lib.usr-is-merged
lib32
lib64
lost+found
media
mnt
opt
proc
root
run
sbin
sbin.usr-is-merged
snap
srv
swapfile
sys
tmp
usr
var

The important folders#

FolderContains
/homeEach user's personal folder, such as /home/asha
/rootThe home folder of the administrator
/etcSystem-wide configuration files
/varFiles that change: logs, caches, databases
/var/logLog files
/tmpTemporary files, usually removed on reboot
/usrInstalled programs and libraries
/usr/binMost commands
/bin, /sbinEssential commands; on Ubuntu these link to /usr
/optOptional software installed by hand
/devDevices, such as disks
/procLive information about the system
/mnt, /mediaPlaces to attach disks

You do not need to memorise them, but /home, /etc, /var/log and /tmp come up constantly.

Everything is a file#

Linux represents most things as files, even information about the system. You can read these with normal commands:

Terminal
cat /etc/hostname
head -n 2 /etc/os-release
grep -c processor /proc/cpuinfo
ls -l /bin
Output
laviyx
PRETTY_NAME="Ubuntu 24.04.5 LTS"
NAME="Ubuntu"
2
lrwxrwxrwx 1 root root 7 Apr 22  2024 /bin -> usr/bin

The l at the start of the last line means a symbolic link, a shortcut to another location.

Absolute and relative paths#

A path says where a file is.

  • An absolute path starts at /, and it means the same thing wherever you are.
  • A relative path starts from your current folder.
Terminal
pwd
cat /home/asha/work/reports/june.txt
cat work/reports/june.txt
cd work/images
cat ../reports/june.txt
cd ~
Output
/home/asha
Sales
Sales
Sales

All three commands read the same file.

SymbolMeaning
/Root, when at the start; otherwise a separator
~Your home folder
.The current folder
..The parent folder

Scripts should usually use absolute paths, because a relative path depends on where the script was started.

See the structure#

tree draws folders. It may need installing first (sudo apt install tree):

Terminal
tree work
Output
work
├── images
└── reports
    └── june.txt

3 directories, 1 file

A symbolic link points to another path:

Terminal
ln -s work/reports/june.txt latest.txt
ls -l latest.txt
cat latest.txt
Output
lrwxrwxrwx 1 asha asha 21 Nov  5 06:28 latest.txt -> work/reports/june.txt
Sales

If the original is deleted, the link is left "dangling", and it no longer works.

Hidden files#

Names that start with a dot are hidden from a plain ls. They are often settings, such as .bashrc, the file that configures your shell:

Terminal
ls -A | grep '^\.'
Output
.bash_logout
.bashrc
.profile

Common mistakes#

Practice#

Practice exercise

Print the first line of /etc/passwd, then count how many files and folders are directly inside /etc that end in .conf.

Show hint

head -n 1 prints the first line. ls /etc/*.conf | wc -l counts names.

Show solution
Terminal
head -n 1 /etc/passwd
ls -d /etc/*.conf | wc -l
Output
root:x:0:0:root:/root:/bin/bash
34

Key takeaway#

Next: Creating, Copying and Deleting Files.

Finished this lesson?