Path Navigation Tricks
Advanced Path Navigation Techniques
1. Wildcard Characters
Wildcard characters help you navigate and manage files more efficiently:
Wildcard |
Meaning |
Example |
* |
Matches any characters |
ls *.txt |
? |
Matches single character |
ls file?.txt |
[] |
Matches character ranges |
ls file[1-3].txt |
2. Shortcut Symbols
graph LR
A[~] --> B[Home Directory]
C[.] --> D[Current Directory]
E[..] --> F[Parent Directory]
G[-] --> H[Previous Directory]
3. Advanced Navigation Commands
## Quick return to previous directory
$ cd -
## Go to home directory
$ cd ~
## Navigate multiple levels up
$ cd ../../../
## Create and move to directory in one command
$ mkdir -p /path/to/new/directory && cd $_
4. Tab Completion Techniques
## Partial path completion
$ cd /ho[TAB] ## Autocompletes to /home/
## Multiple matching completion
$ ls Do[TAB][TAB] ## Shows all matching directories
5. Path Manipulation with Environment Variables
## View current path
$ echo $PATH
## Temporarily add new directory to path
$ export PATH=$PATH:/new/directory/path
6. Recursive Path Operations
## Find files recursively
$ find /home -name "*.log"
## Copy files across directories
$ cp -R /source/directory /destination/directory
Pro Tips for Efficient Navigation
- Use
pushd
and popd
for directory stack management
- Leverage shell history with
!!
and !$
- Create aliases for frequently used long paths
LabEx recommends mastering these tricks to significantly improve your Linux navigation efficiency.