Linux File System
LINUX FILESYSTEM HIERARCHY
Chapter 6 - RH124 Hands-On Focus
FILESYSTEM TREE OVERVIEW
- Single inverted tree structure: The entire filesystem is organized as a single tree with
/ (the root directory) at its top. - Directories branch downward from /: All other directories and files create subdirectories under the root directory.
- All paths:
- Absolute paths: Start from the root directory
/. - Relative paths: Based on the current directory the user is in.
IMPORTANT DIRECTORIES
- /boot: Contains bootloader files essential for the system startup.
- /dev: Contains device files which represent hardware devices.
- /etc: Holds system configuration files for the operating system and installed applications.
- /home: Directory containing user data, structured per user (e.g.,
/home/username). - /root: The home directory for the root user (the superuser or admin).
- /run: Contains runtime process data that is maintained during system uptime.
- /tmp: Temporary files are stored here, often cleared at boot.
- /usr: Contains user programs and libraries, typically for user applications.
PATH TYPES
- Absolute Path: Always starts with
/, representing the complete path from the root. - Relative Path: Depends on the current working directory.
- Case Sensitivity: Paths in Linux are case-sensitive, so
/Home and /home refer to different directories. - Filename Spaces: To avoid issues, it is advised to refrain from using spaces within filenames.
USEFUL COMMANDS
pwd: Print working directory, displays the current path.ls: List files in the current directory. Can be used with options:-l: Long listing format, shows detailed file information.-a: Includes hidden files (those starting with a dot).-R: Lists files in the directory and all subdirectories recursively.
cd: Change directory, used to navigate between directories.touch: Create or update the timestamp of a file.
HANDS-ON PRACTICE: EXPLORING DIRECTORIES
- Try Commands:
pwd: To see the current directory.ls on /etc to list files in system configurations.ls -1 /var/log: List files in /var/log in a single column.ls -a ~: List all files, including hidden ones in the home directory.
HANDS-ON: NAVIGATING
- Try Commands:
cd /var/log: Change to the /var/log directory.cd ..: Move up one directory level to the parent directory.cd -: Switch back to the previous directory you were in.cd ~/Documents: Navigate to the Documents directory under your home.
HANDS-ON: CREATING FILES
- Try Commands:
touch ~/Documents/test1.txt: Create a file named test1.txt in Documents.touch ~/Videos/movie1.ogg: Create a file named movie1.ogg in Videos directory.
- Verify Created Files: Use
ls on Documents and Videos to check the existence of the files.
HIDDEN FILES & SPECIAL DIRS
.: Represents the current directory...: Represents the parent directory.- Files starting with
. are considered hidden and do not show up in regular listings unless specified. - Try Command: Use
ls -la ~ to display all files, including hidden ones in the home directory.
PRACTICE CHALLENGE
- Navigate to
/etc and list all files within that directory using ls. - Create 2 practice files in
~/tmp_test directory. - Move up two directories using relative paths (e.g.
cd .. twice). - Return to the original directory using
cd - multiple times.