Linux pwd Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux pwd Guide
Complete beginner-friendly guide to pwd on Linux, covering Arch Linux, CachyOS, and other distributions including showing current directory, absolute paths, and directory information.
Table of Contents
Understanding pwd
What is pwd?
pwd (print working directory) shows current directory.
Uses:
- Current location: See where you are
- Absolute path: Get full path
- Scripts: Use in scripts
- Navigation: Confirm location
Why it matters:
- Orientation: Know your location
- Scripts: Reference current directory
- Debugging: Verify paths
pwd Basics
Show Current Directory
Basic usage:
# Show current directory
pwd
# Output: /home/username
Physical vs Logical
Path types:
# Physical path (follows symlinks)
pwd -P
# Logical path (default)
pwd -L
Path Information
In Scripts
Use in scripts:
#!/bin/bash
CURRENT_DIR=$(pwd)
echo "Current directory: $CURRENT_DIR"
With Variables
Store path:
# Store in variable
DIR=$(pwd)
cd /other/directory
cd "$DIR"
Practical Examples
Navigation Helper
Check location:
# Before changing
pwd
# Change directory
cd /some/path
# Verify
pwd
Troubleshooting
pwd Not Found
Check installation:
# Check pwd
which pwd
# Usually in coreutils
# Install if missing
sudo pacman -S coreutils
Summary
This guide covered pwd usage, current directory display, and path information for Arch Linux, CachyOS, and other distributions.
Next Steps
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.