Chapter 3.1 - Introduction to the File System
Learning Objectives
By the end of this chapter, you will be able to:
- Understand what the Linux file system is
- Explain the hierarchical structure
- Distinguish between different file types
- Understand absolute and relative paths
What is the File System?
The Linux file system organizes data on the disk into files and directories. It follows a unique hierarchical structure with / (root) as the starting point.
Characteristics:
- Hierarchical structure (tree)
- A single starting point:
/ - Absolute and relative paths
- Case-sensitive (uppercase/lowercase)
Why this Structure?
Advantages of the Hierarchy
Organization:
- Clear separation of functions
- Easy to navigate
- Standardized (FHS - Filesystem Hierarchy Standard)
Security:
- Permissions per directory
- User isolation
- System file protection
File Types
Regular Files
Files containing data:
- Texts, images, executables, etc.
- Identified by
-inls -l
Directories
Containers of files:
- Organize files
- Identified by
dinls -l
Symbolic Links
Pointers to other files:
- Similar to Windows shortcuts
- Identified by
linls -l
Devices
Representations of hardware:
/dev/sda(disk)/dev/tty(terminal)- Identified by
b(block) orc(character)
Absolute vs Relative Paths
Absolute Path
Always starts with /:
/home/user1/documents/file.txt
/etc/passwd
/usr/bin/ls
Advantages:
- Always valid from anywhere
- Clear and explicit
Relative Path
Relative to the current directory:
# If you are in /home/user1
documents/file.txt # Relative
./documents/file.txt # Same thing
../user2/documents/file.txt # Parent then user2
Special symbols:
.: Current directory..: Parent directory~: User's home directory
Standard Structure (FHS)
Essential Directories
Quick description:
/bin: Essential commands (ls, cp, mv)/etc: System configuration/home: User directories/usr: Programs and libraries/var: Logs, cache, variable data/tmp: Temporary files
Basic Navigation
Essential Commands
# See where you are
pwd
# Change directory
cd /home/user1
cd ~ # Home
cd .. # Parent
cd - # Previous
# List files
ls # Simple list
ls -l # Details
ls -la # All (including hidden)
ls -lh # Human-readable sizes
ls -lt # Sorted by date
# Create directories
mkdir my_repo
mkdir -p full/path # Create parents if necessary
# Remove
rmdir empty_repo
rm -r repo # Recursive
Summary
In this chapter, you learned:
File System: Hierarchical organization of data
Structure: Tree with / as root
Types: Files, directories, links, devices
Paths: Absolute (/) vs relative (., .., ~)
FHS: Standard directory structure
Navigation: pwd, cd, ls, mkdir, rmdir
Next Steps
Chapter 3.2: Directory Structure
Chapter 3.3: Navigation and Basic Commands
Chapter created on: December 2024