Navigating File Paths
Understanding Path Types in Linux
Linux supports two primary path types: absolute and relative paths. Understanding these path navigation techniques is crucial for efficient file system management.
graph LR
A[Path Types] --> B[Absolute Paths]
A --> C[Relative Paths]
B --> D[Start from Root /]
C --> E[Start from Current Directory]
Path Navigation Commands
Command |
Function |
Example |
pwd |
Print Working Directory |
pwd |
cd |
Change Directory |
cd /home/user |
ls |
List Directory Contents |
ls /var/log |
Absolute Path Navigation
Absolute paths start from the root directory ("/") and provide the complete path to a file or directory.
## Navigate using absolute path
cd /home/username/Documents
pwd
Relative Path Navigation
Relative paths are defined in relation to the current working directory, using shortcuts like "." and ".."
## Current directory
cd .
## Parent directory
cd ..
## Navigate relatively
cd ../Documents
Path Traversal Techniques
## Multiple directory jumps
cd ../../home/username
## Combine navigation methods
ls ../Documents/*.txt
These examples demonstrate flexible path navigation strategies in the Linux filesystem.