The Linux file system is very specific and can be confusing to the new user of the system. Where are your files? Why are there so many folders and subfolders?
The goal of today's article is to give you an overview of the file system on your Raspberry Pi (as well as on any Linux device).
Raspberry Pi file system
Linux file system
The first thing to understand is that the Raspberry Pi does not use a specific file system tree, it is a standard from the Linux Foundation called ' Filesystem Hierarchy Standard ' or FHS.
So you will basically find the same hierarchy on any Linux distribution.
For those interested in this, you can find all of the information in the article: Understanding file and directory systems on Linux operating systems.
Linux tree
Most of the common mistakes come from misunderstandings. So, as said before, you can view the file hierarchy as a tree, with / as the root directory and each subdirectory as a new branch.
In this figure, I have shown it more like an organization chart.

The colored boxes are directories and the white is the file. At the top there is the root directory: /.
Then, home and etc are subdirectories, the two big branches pi and user2 are subdirectories from home , and the passwd and hosts are the two files in etc.
For example, the file location is specified as / etc / passwd. Since / and etc are directories where you can find files, you can add / for each subdirectory and filename at the end.
Another example: /home/pi/Documents/MyDoc.doc. You have to go through /, home, pi and Documents to find it from the root directory.
File system format
Actually, Raspberry Pi Foundation uses the boot partition in FAT format (good news for Windows users, as you can read and write on it) and Linux format for primary partition (possibly EXT4) .
You have the information, but nothing can be done with it, because the format is included in the image file and you cannot control it.
The most useful directories to know
/ home
Home is a short version of "home directories". It contains a subdirectory for each user (eg / home / pi ).
Each user folder contains personal data, like preferences, documents, downloaded files, etc.
On Raspberry Pi OS Desktop, you will get many subfolders by default under / home / pi:
At this point, it's actually close to Windows.
/ root
/ root is the same as / home for admin users. Basically, we don't use it on the Raspberry Pi. However, if you are logged in with root privileges, you will go to this directory, as the home directory.
/ etc
Etc contains all the configuration files. There are several possible explanations for this name, but perhaps the Editable Text Configuration is the most appropriate.
There are several files available directly in / etc, for example:
And for more complex configurations, you'll often find a specific subfolder for them:
If you're looking for a configuration file, it might be somewhere in / etc.
/ var
Var stands for "Variable files". It means that files are modified during program execution (eg log file).
Here are the most common subfolders you need to know:
/ usr
/ usr mainly contains application files that you do not need to touch (like binaries and libraries). Saving scripts in a directory like / home / pi / scripts is probably a good idea.
/ bin
/ bin is something similar for the required command binaries. There are no subdirectories in this directory, only binaries like ping, cp / mv / rm or nano
In fact, these are the only available binaries when you boot in single-user mode. Any user can use them.
/ opt
/ opt stands for optional and it is mainly used for optional application packages.
For example, if you install AlexaPi on your Raspberry Pi, the documentation guides you to download the files here, then you use the binary from / opt / AlexaPi.
/ media and / mnt
/ media and / mnt are optional but you will probably use them using USB.
In theory, / mnt is for a temporarily mounted file system and / media for removable media. So with USB you will create a directory such as / media / usb and mount it in this directory.
ncG1vNJzZmismaXArq3KnmWcp51ktbDDjJ2mnqtdqbWmedGaqqmalae%2FunnPomSfoZyaerTF0q2cpmWnpL%2Bs