1.3. Terminal Navigation#
Now that you understand the philosophy behind Unix, it’s time to get hands-on. This section introduces you to the most essential terminal commands for navigating your system and managing files. These commands form the foundation for everything else you’ll learn.
1.3.1. Opening Your Terminal#
Before you can run any commands, you need to open a terminal:
On Windows:
Press
Win + R, type “powershell”, and press EnterOr search for “PowerShell” in the Start Menu
Note: PowerShell is the modern command-line environment on Windows (preferred over Command Prompt or
cmd)
On macOS:
Press
Cmd + Space, type “Terminal”, and press EnterOr find Terminal in Applications → Utilities
On Linux (Ubuntu/Debian/CentOS):
Press
Ctrl + Alt + TOr right-click on the desktop and select “Open Terminal”
What you’ll see:
On Windows (PowerShell):
PS C:\Users\username>
On macOS/Linux:
user@computer ~ $
This is the shell prompt. It tells you:
user(macOS/Linux) orusername(Windows): Your user accountcomputer: Your hostname (macOS/Linux only)~(macOS/Linux) orC:\Users\username(Windows): Your current directory (home directory)$(macOS/Linux): Ready for input (# would mean you’re root)PS(Windows): Indicates PowerShell prompt
1.3.2. Understanding the Filesystem#
Before navigating, you need to understand how Linux organizes files:
/ (root)
├── home/ # User home directories
│ └── user/ # Your personal files
├── etc/ # Configuration files
├── var/ # Variable data (logs, databases)
├── bin/ # Essential programs
├── usr/ # User programs and data
└── tmp/ # Temporary files
Everything starts from / (the root directory). Your personal files live in /home/username/ (or ~ for short).
1.3.3. Navigation Commands#
1.3.3.1. pwd — Print Working Directory#
Shows your current location in the filesystem:
$ pwd
/Users/alice
This tells you you’re in the /Users/alice directory.
1.3.3.2. cd — Change Directory#
Moves to a different directory:
# Go to your home directory
$ cd ~
$ cd /
# Go to a specific directory
$ cd /usr/bin
# Go up one level
$ cd ..
# Go back to previous directory
$ cd -
# Go to home directory (same as cd ~)
$ cd
Important paths:
/= Root directory (top level)~= Your home directory.= Current directory..= Parent directory (one level up)
1.3.3.3. ls — List Files#
Shows what’s in the current directory:
# Simple list
$ ls
# Detailed list with permissions, size, date
$ ls -l
# Include hidden files (starting with .)
$ ls -a
# Human-readable sizes (KB, MB, GB)
$ ls -lh
# Combine options
$ ls -lah
Example output:
-rw-r--r-- 1 alice staff 4096 Dec 19 10:30 document.txt
drwxr-xr-x 3 alice staff 4096 Dec 19 10:20 projects
Breaking this down:
-rw-r--r--: File permissionsalice: Ownerstaff: Group4096: File sizeDec 19 10:30: Last modifieddocument.txt: Filename
1.3.4. File and Directory Operations#
1.3.4.1. mkdir — Create Directory#
Creates a new folder:
$ mkdir my_project
$ mkdir -p path/to/nested/folder # Create all parent directories
1.3.4.2. touch — Create Empty File#
Creates a new empty file (or updates timestamp):
$ touch myfile.txt
1.3.4.3. cp — Copy Files#
Copies files or directories:
# Copy a file
$ cp source.txt destination.txt
# Copy a directory and its contents
$ cp -r source_dir/ dest_dir/
1.3.4.4. mv — Move or Rename#
Moves files or renames them:
# Rename a file
$ mv oldname.txt newname.txt
# Move file to different directory
$ mv myfile.txt /path/to/destination/
# Move and rename at once
$ mv /old/path/oldname.txt /new/path/newname.txt
1.3.4.5. rm — Remove Files#
Deletes files (careful—it’s permanent!):
# Delete a file
$ rm unwanted.txt
# Delete a directory and all contents
$ rm -r my_folder/
# Force delete (don't ask for confirmation)
$ rm -f file.txt
Warning: There’s no trash in the terminal. Use rm carefully!
1.3.4.6. cat — View File Contents#
Shows the entire contents of a file:
$ cat myfile.txt
For long files, this will scroll past quickly. Use less or more for paging:
$ less myfile.txt # Press 'q' to quit, space/arrows to scroll
$ more myfile.txt # Similar to less but older
1.3.5. Understanding Command Syntax#
Commands follow a pattern:
command [options] [arguments]
Example:
$ ls -l /usr/bin
ls= command (list files)-l= option (long format)/usr/bin= argument (which directory)
Options vs Arguments:
Options modify behavior (usually start with
-or--)Arguments tell the command what to work on
1.3.6. Getting Help#
Every command has built-in documentation:
1.3.6.1. man — Manual Pages#
Detailed documentation for any command:
$ man ls # Read about the ls command
$ man pwd # Read about pwd
Navigate with space (next page), arrow keys, and type q to quit.
1.3.6.2. –help or -h#
Quick help summary:
$ ls --help # Show all options for ls
$ grep -h # Show help for grep
1.3.6.3. whatis#
One-line description:
$ whatis ls
ls (1) - list directory contents
1.3.7. Common Patterns and Tips#
1.3.7.1. Listing with Details#
# See everything with details
$ ls -lah
# See only directories
$ ls -d */
# Sort by modification time
$ ls -lt
1.3.7.2. Finding Your Way#
# See full path to current location
$ pwd
# Go home quickly
$ cd
# See where you came from
$ cd -
1.3.7.3. Safe Deletions#
Until you’re confident, verify what you’re deleting:
# See what would be deleted
$ ls file_*.txt
# Then delete
$ rm file_*.txt
1.3.8. Practice Exercise#
Try these commands in your terminal:
Navigate the filesystem:
pwd # Where am I? cd / # Go to root ls # What's here? cd ~ # Go home pwd # Where am I now?
Create and manage a test folder:
mkdir test_folder # Create folder cd test_folder # Enter it touch file1.txt # Create empty file ls # List contents cd .. # Go back up rm -r test_folder # Delete folder
Explore system directories:
cd /usr/bin # Look at installed programs ls | head # See first 10 man ls # Read documentation
1.3.9. Key Takeaways#
✓ Use pwd to know where you are
✓ Use cd to move around
✓ Use ls to see what’s in a directory
✓ Use mkdir and touch to create things
✓ Use cp, mv, rm to manage files
✓ Use man when you forget how a command works
✓ Always think before using rm on important files
These commands are the foundation. Master them, and you’ll feel at home in the terminal.