Linux / Bash
Beginner
1 min read
Navigating with cd, pwd, and Shortcuts
Example
# Print current directory
pwd
# Navigate to an absolute path
cd /var/log
# Navigate up two levels
cd ../..
# Return to previous directory
cd -
# Push current dir onto stack and cd to /tmp
pushd /tmp
# List the directory stack
dirs -v
# Return to last pushed directory
popd
# ---- find examples ----
# Find files by name (case-insensitive)
find /home -iname "*.txt"
# Find files modified in the last 7 days
find /var/log -mtime -7
# Find files larger than 100 MB
find / -size +100M -type f 2>/dev/null
# Find empty files
find . -type f -empty
# Find and delete .tmp files (with confirmation prompt removed)
find /tmp -name "*.tmp" -type f -delete
# Find files owned by a specific user
find /home -user alice
# Execute a command on each found file
find . -name "*.log" -exec gzip {} \;
Related Resources
Linux / Bash Reference
Complete tag & property list
Linux / Bash How-To Guides
Step-by-step practical guides
Linux / Bash Exercises
Practice what you've learned
More in Linux / Bash