Terminal

Lesson 2

The terminal (also called command line or CLI) is your direct line of communication with your computer. Instead of clicking buttons and menus, you type commands to get things done. This might feel strange at first, but it’s incredibly powerful—and essential for cloud engineering.

Think of it this way: using a graphical interface is like ordering from a restaurant menu, while using the terminal is like being able to walk into the kitchen and cook exactly what you want. You’ll use the terminal to deploy cloud resources, manage servers, and automate tasks that would take hours to do manually.

Terminal Vocabulary:

  • Directory = Folder (we’ll use these terms interchangeably)
  • Change directory = Navigate to/open a folder
  • Working directory = The folder you’re currently in
  • Command = An instruction you type to make something happen

Table of contents

  1. Terminal
    1. Essential Commands You’ll Master
    2. Let’s Start Practicing!
      1. Step 1: Opening Your Terminal
      2. Step 2: Finding Your Location - pwd
      3. Step 3: See What’s Around You - ls
      4. Step 4: Navigate to a Folder - cd
      5. Step 5: Create Your First Folder - mkdir
      6. Step 6: Create Files - touch
      7. Step 7: Delete Files - rm
      8. Step 8: Delete Folders - rm -rf
    3. Command Reference Card
    4. Pro Tips for Success
    5. Customizing Your Terminal with .bashrc
      1. Finding Your Configuration File
      2. Common Customizations
    6. Editing Files with Nano
      1. Basic Nano Commands
      2. Try It Yourself
    7. Practice Exercise
    8. What You’ve Accomplished

Essential Commands You’ll Master

By the end of this lesson, you’ll be comfortable with these everyday commands:

CommandWhat it doesReal-world use
pwdShows your current location“Where am I?”
lsLists files and folders“What’s in here?”
cdNavigate to a folder“Go to…”
mkdirCreate a new folder“Make a folder”
touchCreate a new file“Make a file”
rmDelete a file“Delete this”
rm -rfDelete a folder“Delete this folder”

Let’s Start Practicing!

We’ll walk through each command step-by-step. Don’t worry about memorizing everything—you’ll naturally remember these through practice.

Step 1: Opening Your Terminal

Mac Users:

  1. Press Cmd + Space to open Spotlight
  2. Type “Terminal”
  3. Press Enter

Linux Users:

  1. Press Ctrl + Alt + T
  2. Or search for “Terminal” in your applications

Windows Users:

  1. Search for “Command Prompt” or “PowerShell”
  2. For the best experience, consider installing Windows Terminal

You’ll see a window that looks something like this:

terminal

Don’t be intimidated by the blank screen—this is your command center!

Step 2: Finding Your Location - pwd

Your first command! Type this and press Enter:

pwd

What happens: You’ll see something like /Users/yourname (Mac) or /home/yourname (Linux)

pwd

What it means: pwd stands for “print working directory”. It’s like asking “What folder am I in right now?” This is your home directory—your personal space on the computer.

Pro tip: Lost in the terminal? Type pwd to instantly see where you are.

Step 3: See What’s Around You - ls

Now let’s see what’s in your home directory:

ls

What happens: You’ll see a list of folders and files

ls

Understanding the output:

  • Folders often appear in blue or bold
  • Files appear in regular text or different colors
  • Look for familiar names like Desktop, Documents, Downloads

Can’t see Desktop? No problem! Pick any folder you see—we’ll use that instead.

Step 4: Navigate to a Folder - cd

Let’s move to your Desktop folder:

cd Desktop

(If you don’t have Desktop, use any folder name from your ls output)

cd-1

Let’s verify we moved:

  1. Type pwd - Notice the path now ends with /Desktop
  2. Type ls - You’ll see the contents of your Desktop

What just happened: cd stands for “change directory”. You just navigated into a folder, exactly like double-clicking a folder in your file explorer.

Step 5: Create Your First Folder - mkdir

Let’s create a practice folder:

mkdir learn-terminal

mkdir

Verify it worked:

ls

You should see learn-terminal in the list!

Now let’s go inside:

cd learn-terminal
ls

Notice nothing appears after ls? That’s because our new folder is empty—let’s fix that!

Step 6: Create Files - touch

Let’s create some files in our practice folder:

touch notes.txt

Verify with:

ls

touch

Try creating more files:

touch README.md
touch script.js
touch data.json

Check your work:

ls

You should see all four files listed!

File Extensions: The part after the dot (.txt, .md, .js) tells programs what type of file it is. You’ll use .tf for Terraform files later!

Step 7: Delete Files - rm

Let’s clean up by removing a file:

rm notes.txt

Verify it’s gone:

ls

rm

Important: rm permanently deletes files—there’s no trash bin! Always double-check before using it.

Practice: Try deleting another file:

rm data.json
ls

Step 8: Delete Folders - rm -rf

First, let’s go back up one level:

cd ..

What’s ..? Two dots mean “parent directory”—the folder that contains the current one.

Check where you are:

pwd

You should be back in Desktop (or wherever you started).

Now delete the practice folder:

rm -rf learn-terminal

rm-rf

Verify it’s gone:

ls

Warning: rm -rf is powerful and dangerous! It deletes folders and everything inside them permanently. Always triple-check your command before pressing Enter.

Command Reference Card

Save this for quick reference:

# Navigation
pwd                 # Where am I?
ls                  # What's here?
cd folder-name      # Go into a folder
cd ..               # Go back up one level
cd ~                # Go to home directory

# Creating
mkdir folder-name   # Create a folder
touch file.txt      # Create a file

# Deleting
rm file.txt         # Delete a file
rm -rf folder-name  # Delete a folder and everything in it

Pro Tips for Success

  1. Tab Completion: Start typing a folder name and press Tab—the terminal will complete it for you!
  2. Up Arrow: Press the up arrow to see previous commands
  3. Clear Screen: Type clear when your terminal gets cluttered
  4. Get Help: Most commands have a --help option (try ls --help)

Customizing Your Terminal with .bashrc

Your terminal has a configuration file called .bashrc (or .zshrc on newer Macs) that runs every time you open a new terminal. This is where you can add shortcuts, customize your prompt, and set up your development environment.

Finding Your Configuration File

# For Linux and older Macs (using bash)
nano ~/.bashrc

# For newer Macs (using zsh)
nano ~/.zshrc

Common Customizations

Here’s a practical example - adding shortcuts (called aliases) to your configuration:

# Shortcuts for common commands
alias ll='ls -la'              # List all files with details
alias ..='cd ..'               # Go up one directory
alias ...='cd ../..'           # Go up two directories
alias awslogin='aws sso login' # Quick AWS login

# Show current git branch in terminal prompt
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

# Add colors and git branch to your prompt
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

After adding these lines, save and reload your configuration:

source ~/.bashrc  # or source ~/.zshrc for Mac

bashrc-customization

Now you can type ll instead of ls -la, and your terminal will show which git branch you’re on!

Editing Files with Nano

Nano is a beginner-friendly text editor that works right in your terminal. Unlike more complex editors like Vim, Nano shows all available commands at the bottom of the screen.

Basic Nano Commands

# Open a file (creates it if it doesn't exist)
nano filename.txt

# Inside nano:
# - Type normally to add text
# - Use arrow keys to move around
# - Ctrl+S to save
# - Ctrl+X to exit
# - Ctrl+K to cut a line
# - Ctrl+U to paste

Try It Yourself

  1. Create and edit a new file:
    nano my-first-file.txt
    
  2. Type some text:
    Hello from the terminal!
    This is my first file edited in nano.
    
  3. Save with Ctrl+S
  4. Exit with Ctrl+X
  5. View your file:
    cat my-first-file.txt
    

nano-editor-demo

Nano is perfect for quick edits to configuration files, scripts, and documentation. As you grow more comfortable, you might explore more powerful editors like Vim or Emacs, but Nano will always be there as your reliable quick-edit tool.

Practice Exercise

Before moving on, try this mini-project to cement your skills:

  1. Create a folder called aws-learning
  2. Go into that folder
  3. Create three files: notes.md, commands.txt, progress.log
  4. List the contents to verify
  5. Delete progress.log
  6. Go back up one level
  7. Delete the entire aws-learning folder
Click for solution ```bash mkdir aws-learning cd aws-learning touch notes.md commands.txt progress.log ls rm progress.log cd .. rm -rf aws-learning ```

What You’ve Accomplished

✅ Opened and navigated the terminal
✅ Created and deleted files and folders
✅ Learned essential navigation commands
✅ Built confidence with the command line

These skills are your foundation for everything that follows. In AWS, you’ll use these same commands to manage cloud servers, deploy applications, and automate infrastructure.

Ready for the cloud? Let’s set up your AWS account!