Navigate the filesystem using command-line commands
Create, move, copy, and delete files and directories
Use essential commands for daily development tasks
Understand environment variables and PATH
The terminal (also called command line or shell) is where developers spend a significant amount of their time. While GUIs are intuitive, the terminal offers speed, precision, and automation that no graphical interface can match. Mastering basic terminal commands will make you a more efficient developer.
Terminal Basics
A shell is the program that processes your commands. The most common shells are bash (default on Linux/older macOS) and zsh (default on newer macOS). Windows uses PowerShell or cmd, but many developers install WSL (Windows Subsystem for Linux) for a Unix-like experience.
Term
Definition
Shell
The command interpreter (bash, zsh, fish)
Terminal
The application window running the shell
Prompt
The text showing you can type (usually $ or %)
Command
An instruction you type and execute
Arguments
Additional info passed to a command
Flags/Options
Modifiers like -r or --verbose
Think of the shell as a translator between you and the operating system. You type human-readable commands; it converts them into actions the OS understands.
Navigation Commands
The filesystem is a tree structure with directories (folders) containing files and subdirectories. Navigation commands let you move around this tree.
Command
Description
Example
pwd
Print working directory (where you are)
pwd → /Users/alice/projects
ls
List directory contents
ls -la (detailed with hidden files)
cd
Change directory
cd projects or cd .. (parent)
cd ~
Go to home directory
cd ~ → /Users/alice
cd -
Go to previous directory
Toggle between two directories
Path Types
Type
Starts With
Example
Absolute Path
/ (root)
/Users/alice/projects/app
Relative Path
Current directory
./src/index.js or ../config
Home Shortcut
~
~/Documents
# Navigation examples
pwd # Where am I?
ls # What's here?
ls -la # Detailed list including hidden files
cd ~/projects # Go to projects folder
cd .. # Go up one level
cd - # Go back to previous directory
Filesystem tree diagram showing directory structure
Figure 1: Unix Filesystem Hierarchy — Navigating the Directory Tree
File Operations
Command
Description
Example
touch
Create empty file
touch index.html
mkdir
Create directory
mkdir -p src/components
cp
Copy files/directories
cp file.txt backup.txt
mv
Move or rename
mv old.js new.js
rm
Remove files
rm file.txt
rm -rf
Remove directory recursively
rm -rf node_modules
rm -rf is dangerous! There's no trash can — files are permanently deleted. Always double-check the path before running this command.
Environment variables store configuration that programs can read. The PATH variable is especially important — it tells the shell where to find executable programs.
Command
Description
echo $PATH
Print PATH variable
echo $HOME
Print home directory
export VAR=value
Set environment variable (current session)
env
List all environment variables
which node
Show path to an executable
# Environment variables
echo $PATH # Show executable search paths
echo $HOME # Home directory
export NODE_ENV=development # Set variable for session
which node # Where is node installed?
which npm # Where is npm installed?
Add permanent environment variables to your shell config file: ~/.zshrc (zsh) or ~/.bashrc (bash). Run source ~/.zshrc to reload after editing.