FileSystemStructure
UNIX File System Structure:
- Computers store file locations in a hierarchical structure.
- each file and directory has its own “address”, and that address is called its path
- There are 2 special paths:
- Root is where the address system of the computer starts, symbol
/ - home is where the current user’s location is, symbol.
~$means user is not root.
- Root is where the address system of the computer starts, symbol
$PATHshows the hierarchy of all the path lists when the system is looking for a program.- Absolute vs Relative path:
- An absolute path is an address that starts from one of those two special locations we mentioned above:
- either the “root” (specified with
/) - “home” location (specified with
~/). - A relative path is an address that starts from wherever we are currently sitting.
- either the “root” (specified with
- An absolute path is an address that starts from one of those two special locations we mentioned above:
- Absolute vs Relative path:
Command structure is command argument --> date --h
File System Structure:
- File system in Linux follows a hierarchical order
- In linux , everything is treated like a file (even devices)
| Directory | Funtion | Command | Special Consideration |
|---|---|---|---|
root directory / |
Starting point of the file system | / |
The top-level directory is the root filesystem and contains all of the files required to boot the operating system before other filesystems are mounted, as well as the files required to boot the other filesystems. |
| root subfolder | Subfolder of the root directory | /root |
|
| Binary/ Executable | Contains essential-line tool that are needed for system to run properly : ls cp mv cat are located here. Basic utilities for user. |
bin |
|
| System binaries | Holds specialised system utilities like : - Mounting file systems mount - Checking disk fsck - Shutting down the system shutdown |
sbin |
|
| Library | Many commands that are found in /bin and /sbin rely on shared libraries and are found here. - There are also kernel modules that are loaded into the Linux kernel on demand. |
/lib |
|
| Unix System Resources | This contains user-space system applications, libraries, and documentation. |
/usr |
This area is read-only and managed by the system. |
| Bootable | This folder contains all the files necessary to boot the system such as: - Linux initial RAM disk - Initial - GRUB bootloader files |
/boot |
grub.cfg file tells the system how to load the OS. |
| Device | Contains device files that act like interfaces to the hardware. There are two main type of device files: - Block Devices --> Harddrive that handles data as a chunk. - Character Devices --> Keyboard that handles data as a stream of character. |
/dev |
These files are managed dynamically, Linux add or removes them based on hardware changes. |
| Editable text configuration | Central location for system-wide configuration files | /etc |
Network setting, Password information, etc. Most of these are plain-text files |
| Home directory | User Space, user file, download, etc. This folder are useful to separate user data from system files. | /home |
Hidden files in Linux usually starts with a .like .bashrc |
| Media | Contains data for removable devices. (USB, CD) | /media |
Handles automatically by the system. |
| Mountable | Reserved for manual and temporary mount, that is used during system maintenance. | /mnt |
Needs to be handled manually by advanced user. |
Proc is a virtual file system. It does not contain real files, but provides a dynamic and in-memory view of the system.This is a vital tool for monitoring, debugging and interacting with with system in real-time |
/proc |
Shows the process id Shows CPU info |
|
| Pseudo File System | It acts like a dynamic interface between the Linux kernel and hardware. |
/sys |
sysfcKernel shows information about devices, drivers, and system buses |
| Service | This is where data provided by web servers, FTP servers, or hosted services is stored.srv contains data that services share with others. |
/srv |
Contains service data |
| Variable | Logs, Caches, and more are stored here. It stores system data that change often. | /var |
It contains data that reports system behaviour over time. |