If you are Windows user, you might be familiar with the C: drive. You know, the drive where the Operative System files, your documents and where programs gets installed by default. You may also have a second drive called D:, and maybe even an E: drive, if you have a USB memory stick inserted. You could even have a virtual drive that points to a network share.
Overview of the Linux Filesystem
In Linux it’s very different. The Linux filesystem is just one big monolithic filesystem where everything is stored under the root directory, which is defined with a forward slash, “/”.
From a layman’s perspective, it might look like everything is stored under one drive. It may be so, but not necessary. It depends where the different directories are mounted. It could for example be like this:
The /home directory can be mounted on a 2nd drive
The /proc directory is a virtual filesystem which interacts with the Linux kernel
The /etc directory is indeed stored on the main drive
The /mnt/data directory is mounted on a network share
The /boot/efi directory is mounted on a separate partition on the main drive
The /media/usb1 is a mounted USB drive
You can verify where the different directories are stored by opening up a terminal window and type df -h…
user@computer:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 117G 18G 93G 17% /
/dev/nvme0n1p2 856G 44G 769G 6% /home
/dev/sda1 112M 6,1M 106M 6% /boot/efi
//2001:DB8:1234:B010::8/backup 4,0T 361G 3,6T 9% /mnt/data
/dev/sdb1 29G 24K 27G 1% /media/usb1
…or Alternatively with lsblk. It gives a tree-like structure, but it doesn’t list network drives:
user@computer:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 119,2G 0 disk
├─sda1 8:1 0 113M 0 part /boot/efi
└─sda2 8:2 0 119,1G 0 part /
sdb 8:16 1 28,6G 0 disk
└─sdb1 8:17 1 28,6G 0 part /media/usb1
nvme0n1 259:0 0 931,5G 0 disk
├─nvme0n1p1 259:1 0 61G 0 part [SWAP]
└─nvme0n1p2 259:2 0 870,5G 0 part /home
Note:
sda, sdb, nvme0n1 and so forth represents the physical disks.
sda1, sda2, sdb1 and so forth represents partitions created inside physical disks.
Confusion about file systems, file system types, and directories
There seems to be some confusion about the terms when reading documentation. As far as I understand it:
A directory is a folder containing files and file systems.
A file system defines how to separate files and folders from each other. Think of it like a parking lot with lanes, compared to a parking lot without lanes. The latter can become quite unorganized; it can be hard to find your car, or even retrieve it, if there is no system.
There are many different filesystem types. EXT4 is very popular on linux systems, while Windows uses NTFS. USB drives usually use FAT32 or vFAT. For the parking lot analogy, this defines how wide each parking spot is.
Imporant Directories
I’m going to briefly explain the most common directories that a regular user interacts with.
The /home Directory
This is where you usually would store your personal files; your documents, pictures and other stuff. Under the /home directory, there is a user specific folder created at installation of Linux.
user@computer:/$tree /home -d
/home
├── lost+found [error opening dir]
└── user
├── Desktop
├── Documents
├── Downloads
In the file explorer, you can see some of the folders listed inside your users home directory.
The /media Directory
This is where the additional drives and USB memory sticks mounts by default. In the file explorer, you can find them under “Other Locations” or “Removable Devices”.
The /etc Directory
This is where most programs and OS settings are stored. Unless you are an advanced user, you will seldom have to touch anything here. It’s better to tweak settings through the GUI = Graphical User Interface if you are a beginner.
# A Sample of the /etc filesystem
user@computer:/$ tree -d /etc
/etc
├── acpi
│ └── events
├── alsa
│ └── conf.d
├── alternatives
│ └── sddm-ubuntu-theme -> /usr/share/sddm/themes/breeze
├── apache2
│ └── conf-available
├── apm
│ ├── resume.d
│ ├── scripts.d
│ └── suspend.d
├── apparmor
│ └── init
│ └── network-interface-security
├── apparmor.d
│ ├── abi
│ ├── abstractions
│ │ ├── apparmor_api
│ │ └── ubuntu-browsers.d
│ ├── disable
│ ├── force-complain
│ ├── local
│ └── tunables
│ ├── home.d
│ ├── multiarch.d
│ └── xdg-user-dirs.d
├── apport
│ ├── blacklist.d
│ └── crashdb.conf.d
├── apt
│ ├── apt.conf.d
│ ├── auth.conf.d
│ ├── keyrings
│ ├── preferences.d
│ ├── sources.list.d
│ └── trusted.gpg.d
...
The /opt Directory
Some program files are stored here after you install them.
user@computer:/$ tree -d -L 1 /opt
/opt
├── balenaEtcher
├── brave.com
├── drawio
├── Signal
└── zoom
That concludes the most important file systems. There are more, but these are the ones most people interact with.