The Linux file system is very specific and can be hard to understand for newbies on this system.
Where are my files? Why is there so many folders and subfolders? etc.
The goal of this post today, is to help you to get an overview of the file system on a Raspberry Pi (and on any Linux device)
The Linux file system can be seen like a tree. The / location is the root, where the trunk begins.
Each sub-folder is a big branch (/home, /var, /etc, …), and these branches also have smaller branches (/home/pi, /var/www, /var/lib, …).
We will start by a general overview about the Linux file system (the tree), then list the most useful folders to know, and finally see some common mistakes in the file system usage.
The Raspberry Pi File System
The Linux File system
The first thing to understand is that the Raspberry Pi doesn’t use a specific file system tree, it’s a standard from the Linux Foundation named “Filesystem Hierarchy Standard” or FHS.
So, basically, you’ll find the same hierarchy on any Linux distribution.
For those interested in this, you can find all the information about this standard on the official documentation here.
The Linux tree
I already introduced this concept in the introduction, but I want to illustrate it here because it’s important. Most common mistakes comes from a misunderstanding at this point (we’ll see them later).
So, as I told you, you can see the files hierarchy as a tree, with / as the root folder, and each subfolder as a new branch.
In this picture, I presented it more like an organizational chart, but you can absolutely revert it if you didn’t understand the tree analogy :).

Colored cells are folders, and white are files.
At the top there is the root folder: /
Then home and etc are subfolders, two big branches (there are other ones).
pi and user2 are subfolders from home, passwd and hosts are two files in etc.
The file location is identified as /etc/passwd for example.
So, / and etc because they are the folders where you can find the file, and then you add another / for each subfolder and the file name at the end.
Other example: /home/pi/Documents/MyDoc.doc. You have to go through /, home, pi and Documents to find it from the root folder.
I hope that this notation is clearer now :).
File system format
I also often see this question about the file format used by Raspberry Pi OS, but I don’t think it’s relevant.
In fact, the Raspberry Pi Foundation use a boot partition in a FAT format (good news for people on Windows because you can read and write on it), and a Linux format for the main partition (probably EXT4).
That’s it, you have the information, but you can’t do anything with it, as the format is included in the image file and you can’t control it.
Most useful folders to know
/home
Home is the short version of “home directories”.
It contains one subfolder per user (for example: /home/pi).
Each user directory contains personal data, like preferences, documents, downloaded files etc.
On Raspberry Pi OS Desktop, you’ll get many subfolders by default in /home/pi:
- Videos
- Downloads
- Music
- Pictures
- Desktop
- Etc.
It’s really close from Windows on this point.
/root
/root is the same thing as /home for the administrator user.
Basically, we don’t use it on Raspberry Pi.
But, if you log in as root, you’ll go to this folder as your home folder.
/etc
Etc contains all the configurations files.
There are several explanations given for the name, but the one I prefer is “Editable Text Configuration”.
There are a few files directly available in /etc, for example:
- /etc/resolv.conf: If you want to change your DNS server
- /etc/crontab: For tasks scheduling (more detail here)
- /etc/sudoers: To manage users with the sudo permission
- Etc.
And for more complex configurations where there is several configuration files, you’ll more frequently find a specific subfolder for them:
- /etc/apache2: If you use apache as a web server, this folder contains all the configuration files
- /etc/ssh: same thing for SSH client and server
- /etc/php: same thing for PHP
- Etc.
You understand the concept, if you are looking for a configuration file, it’s probably somewhere under /etc.
/var
Var is the abbreviation of “Variable files”.
It means files that are modified during a program execution (log files for example).
Here are the most common subfolders you need to know:
- /var/log: contains all the system log files
- /var/www: will be used as soon as you install a web server, it’s the root folder for the web server (public files need to be in /var/www/html)
- /var/lib/mysql: same thing for a MySQL server, it contains all database files. Generally, other database engines also have their files somewhere in /var/lib
- /var/mail: mailboxes files
/usr
/usr contains mainly applications files you don’t need to touch (like binaries and libraries).
I generally use /usr/local/bin as the main folder for my scripts because I learned like this, but I don’t know if it’s really a good practice.
Saving your scripts in a folder like /home/pi/scripts is probably a better idea.
/bin
/bin is something similar for essential command binaries.
There is no subfolder in this one, just binaries like ping, cp/mv/rm or nano.
In fact, it’s the only available binaries when you boot in single user mode; any user can use them.
/opt
I didn’t find opt in the standard description, but I often use it, so I add it here.
/opt is the abbreviation of optional, and it’s mainly used for optional application packages.
When I use it, it’s generally for applications that I download on GitHub, not from the Raspberry Pi OS repositories.
For example, if you install AlexaPi on your Raspberry Pi, the documentation tells you to download the files here, and then you use the binary file from /opt/AlexaPi.
/media and /mnt
/media and /mnt are not mandatory, but you’ll probably use them when you use USB drives.
In theory, /mnt is for temporary mounted file systems and /media for removable media.
So if you mount a USB drive, you’ll create a folder like /media/usb and mount it in this folder.