Linux Directory Basics
Understanding Linux Directory Structure
In Linux systems, directories are fundamental organizational units that store files and other directories. Unlike Windows, Linux uses a hierarchical, tree-like structure starting from the root directory (/
).
Root Directory Hierarchy
graph TD
A[/] --> B[bin]
A --> C[home]
A --> D[etc]
A --> E[var]
A --> F[usr]
Key Directory Locations
Directory |
Purpose |
/home |
User home directories |
/etc |
System configuration files |
/var |
Variable data files |
/bin |
Essential user binaries |
/usr |
User utilities and applications |
Directory Naming Conventions
- Directories are case-sensitive
- Use lowercase letters
- Avoid special characters
- Separate words with underscores or hyphens
Basic Directory Operations
Creating Directories
## Create a single directory
mkdir project
## Create nested directories
mkdir -p /home/labex/workspace/demo
Checking Current Directory
## Print working directory
pwd
Navigating Directories
## Change directory
cd /home/labex
cd .. ## Move to parent directory
cd ~ ## Move to home directory
Permissions and Ownership
Linux directories have specific permission settings that control access:
- Read (r): List directory contents
- Write (w): Create or delete files
- Execute (x): Access the directory
## View directory permissions
ls -ld /home/labex
Best Practices
- Organize directories logically
- Use meaningful names
- Maintain consistent structure
- Set appropriate permissions
By understanding these Linux directory basics, users can effectively manage and navigate their system's file structure, a crucial skill for system administration and development with LabEx.