10: OCI ‐ File system structure in Linux - pavankumarchittajallu/OCI_DOC GitHub Wiki
Linux Filesystem Hierarchy Standard (FHS):
/
)
1. Understand the Root Directory (- The Linux file system is organized as a single hierarchical tree starting from the root directory, denoted as
/
. - All files and directories branch out from this root.
- Think of
/
as the top-level folder containing all other directories and files on the system.
2. Explore Main Top-Level Directories
Each top-level directory under /
has a specific purpose:
Directory | Purpose |
---|---|
/bin |
Essential user binaries (commands like ls , cp , mv ) available to all users. |
/sbin |
System binaries used for system administration (e.g., fsck , iptables ), typically root-only. |
/etc |
System-wide configuration files and startup/shutdown scripts. |
/home |
User home directories containing personal files and settings. |
/root |
Home directory for the root user (administrator). |
/usr |
User utilities and applications, including binaries and libraries (/usr/bin , /usr/lib ). |
/var |
Variable data like logs (/var/log ), mail, and temporary files. |
/tmp |
Temporary files, cleared on reboot. |
/dev |
Device files representing hardware (disks, terminals, USBs). |
/proc |
Virtual filesystem with process and kernel info. |
/sys |
Kernel and hardware interface files. |
/media |
Mount points for removable media (USB drives, CDs). |
/mnt |
Temporary mount points for filesystems. |
/opt |
Optional third-party software packages. |
/lib and /lib64 |
Essential shared libraries for binaries in /bin and /sbin . |
/boot |
Bootloader files and Linux kernel images. |
/run |
Runtime data like process IDs and locks. |
/srv |
Data for services like web and FTP servers. |
This structure is fairly consistent across Linux distributions due to the Filesystem Hierarchy Standard (FHS).
3. Use Commands to Explore the Structure
- Open a terminal and navigate to the root directory:
cd /
- List top-level directories with details:
ls -l /
4. Learn Navigation Basics
cd
to change directories:cd /etc
- go to/etc
cd ..
- go up one directorycd ~
- go to your home directory
pwd
to print current directory pathls
to list files and directoriesls -a
to show hidden filesls -l
for detailed info
5. Understand File Types in Linux
- Everything in Linux is a file or a process.
- File types include:
- Regular files: text, binaries, images, etc.
- Directories: special files that contain other files.
- Special files: device files (in
/dev
), symbolic links, sockets, and pipes.
6. Practical Tips
- Use absolute paths (starting with
/
) to specify exact locations. - Use relative paths (from the current directory) for convenience.
- Use tab completion in the terminal to auto-complete file and directory names.
- Use the
find
command to search files by name or type:find /home -name "*.txt"
- Use
stat
to view file metadata (permissions, ownership, timestamps).