Finding Your Way Around
The Linux file system is a tree structure that starts at the root directory /. Every file and folder on your system lives somewhere inside this tree. Learning to navigate it efficiently is the first real skill every Bash user needs.
Where Am I? โ pwd
pwd stands for Print Working Directory. It shows the full path to your current location in the file system.
pwd
# Output example: /home/usernameWhat's Here? โ ls
The ls command lists the contents of a directory. Without arguments it shows the current directory.
# Basic listing
ls
# Long format with details (permissions, size, date)
ls -l
# Show hidden files (files starting with a dot)
ls -a
# Combine flags โ long format + hidden + human-readable sizes
ls -lah
# List a specific directory
ls /etc.), like .bashrc. They won't appear with plain ls; use ls -a.
Moving Around โ cd
cd stands for Change Directory. It moves you to a different location in the file system.
# Go to your home directory
cd ~
cd # same thing โ cd with no argument goes home
# Go to root
cd /
# Go up one level
cd ..
# Go up two levels
cd ../..
# Go to the previous directory
cd -
# Go to an absolute path
cd /var/logAbsolute vs Relative Paths
Understanding the difference is critical:
- Absolute path: Starts from root (
/). Always works regardless of your current location. Example:/home/user/Documents - Relative path: Starts from your current directory. Example:
Documents/notes.txtor../Downloads
Creating & Removing Directories
# Create a directory
mkdir projects
# Create nested directories in one command
mkdir -p projects/bash/scripts
# Create an empty file
touch myfile.txt
# Remove an empty directory
rmdir projects
# Remove a directory with contents (be careful!)
rm -r projectsrm -r deletes a directory and all its contents permanently. There is no trash can. Double-check before running it!
Try It Yourself
Practice navigating and creating directories in the interactive terminal below.
Summary
You now know how to check your location with pwd, list files with ls, move around with cd, and create directories with mkdir. These are commands you'll use every single day.