Linux Root File Structure
flowchart LR
subgraph "Windows History"
A((boot)) --> B["DOS (Disk operating system)"]
B --> C[Windows];
C --> D{{"C:\WINDOWS"}};
A --> E[Windows];
subgraph "Now"
E --> F{{"C:\Program Files"}};
end
end
subgraph "Linux History"
G[BSD] --> H[Unix];
H --> I[Mac OS];
H --> J[Linux];
J --> K[Ubuntu];
J --> Q[Debian];
J --> Z[Raspi]
end
Filesystem Hierarchy Standard (FHS)
- Linux cares capitalization in file or folder name unlike windows.
bin
: binaries for programs and applications, such as ls
, cat
, bash
, etc. (single user mode only, not multi-users)
sbin
: system binaries that a system admin would use, not for normal user. (single user mode only)
- Single user mode is a special mode that boots you in as a root user to allow you to do system repairs updates, etc. Networking is disable because of security issues. When you install a program in Linux, it is not placed in bin or sbin.
boot
: anything to boot the os. Don't touch it.
cdrom
: an old mounting point for your cdrom.
dev
: device, like your hardwares, nvme disk /dev/nvme*
, hardware disk /dev/sda*
, nvidia gpu /dev/nvidia*
, etc. Also, webcam and keyboard. Don't touch this driver folder.
etc
: edit to configure, et cetera (the rest), this stores all system-wide configuration files, such as, network, apt
, ssh
, apache2, nginx
, etc. This is for system wide applications.
home
: folder to store all users desktops.
lib, lib32, lib64
: libraries. Applications can use to perform various functions, they are required by binaries in bin
and sbin
.
media, mnt
: mount. These are for other mounted drives, like floppy disk, usb stick, external hard drive, network drive, or a second hard drive. It is like D:/ and E:/ and so on.
opt
: optional folder for manually installed software. I put opencv here.Can install software created yourself.
proc
: pseudo files that contain information about system processes and resources, for example, every process will have a directory here.
cat /proc/cpuinfo
cat /proc/uptime
root
: root users home folder.
run
: new folder, it is a tempfs file system. It runs in RAM, everything is gone when system is rebooted or shutdown. It is used to store info started early in boot procedure to store runtime info that they use to function.
snap
: to store snap packages.
srv
: service directory where service data is stored. If a server like web server or ftp server is running, you would store files that will be accessed by external users here for better security reason.
sys
: system folder. It is a way to interact with the kernel.
tmp
: temporary directory where files are temporarily stored by applications. Should be empty after reboot.
usr
: user application space. Applications are installed by the user, they are considered non-essential for basic system operation. Most programs installed from source code will end up in the local folders of usr. Larger programs are in share.
var
: variable directory. It contains files and directories that are expected to grow in size, like some of the log files.
- Hide files are in . format.
References