Month 1, Week 1

The Command Line & The Local Environment

Forging the Architect's Toolkit

Module 1: What is the Command Line?

The Professional's Primary Interface

GUI vs. CLI

You are used to a GUI (Graphical User Interface) - clicking icons, dragging windows.

The command line, or CLI (Command-Line Interface), is a text-based way to have a direct conversation with your computer.

Analogy: A GUI is like driving a car with a steering wheel and pedals. A CLI is like telling a hyper-efficient chauffeur exactly what to do with precise, powerful commands.

Why is the CLI Essential for Backend?

  • Power & Speed: Perform complex tasks with a single line of text.
  • Automation: Chain commands together into scripts to automate repetitive work.
  • Remote Access: Most servers do not have a graphical interface. You will manage production systems through a command line (via SSH).
  • The Developer's Standard: Almost all professional backend tools (Git, Docker, databases, cloud services) are primarily controlled via the CLI.

Mastering the command line is not optional. It is the mark of a professional.

Module 2: Core Navigation Commands

Mapping Your Digital World

pwd - "Where am I?"

Print Working Directory. This command tells you your exact location in the filesystem.


                        $ pwd
                        /Users/alex/Documents/projects
                    

ls - "What's in here?"

List. This command shows you the contents of your current directory.


                        $ ls
                        project-alpha   project-beta   notes.txt
                    

Flags add more power. `ls -la` is a common combination:

  • l: Long format (shows permissions, owner, size, date).
  • a: All files (shows hidden files that start with a dot).

cd - "Go over there."

Change Directory. This command moves you to a different folder.

It works with two types of paths:

  • Absolute Path: The full address from the root directory. Starts with `/`.
    $ cd /Users/alex/Documents/projects/project-alpha
  • Relative Path: The path relative to your current location.
    $ cd project-alpha

Special Paths for cd

  • `.` (a single dot): Refers to your **current directory**.
  • `..` (two dots): Refers to the **parent directory** (one level up).
  • `~` (a tilde): A shortcut for your **home directory**.

                        # If you are in /Users/alex/Documents/projects/project-alpha
                        $ cd .. 
                        # You are now in /Users/alex/Documents/projects

                        $ cd ~
                        # You are now in /Users/alex
                    

Module 3: File & Directory Manipulation

Creating and Managing Your Blueprints

mkdir & touch

  • `mkdir `: Make directory. Creates a new folder.
  • `touch `: Creates a new, empty file.

                        $ mkdir my-new-project
                        $ cd my-new-project
                        $ touch index.js
                        $ ls
                        index.js
                    

cp & mv

  • `cp `: Copy a file or directory.
  • `mv `: Move a file or directory. This is also how you rename files.

                        # Copying a file
                        $ cp index.js app.js

                        # Renaming a file
                        $ mv app.js server.js
                    

rm: The Point of No Return

Remove. This command deletes files and directories permanently. There is no trash bin.

  • `rm `: Deletes a file.
  • `rm -r `: Deletes a directory and all its contents recursively. The -r flag is for "recursive".

Use this command with extreme caution. Measure twice, cut once.

Mid-Lecture Knowledge Check

Module 4: The System's Toolkit

PATH & Package Managers

The PATH Environment Variable

Have you ever wondered how your shell knows what `ls` or `node` means? It looks for them in a special variable called the PATH.

The `PATH` is a list of directories. When you type a command, the shell searches each directory in that list until it finds an executable file with that name.


                        # You can view your PATH with this command
                        $ echo $PATH
                        /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
                    

This is why installing software often involves "adding it to your PATH."

Package Managers: The Developer's App Store

A package manager automates the process of installing, upgrading, configuring, and removing software packages.

They solve complex problems like dependencies (when one program needs another to run).

  • macOS: Homebrew (`brew`)
  • Debian/Ubuntu Linux: APT (`apt`)

Module 5: Forging the Local Environment

Installing Your Core Tools

The Architect's Toolkit

We will install the non-negotiable tools for modern backend development.

  1. A professional code editor: Visual Studio Code (VS Code)
  2. A version manager for Node.js: nvm
  3. The JavaScript runtime: Node.js
  4. The version control system: Git

Installation Steps

We will walk through this together. The specific commands vary by OS.

  • VS Code: Download from the official website: `code.visualstudio.com`
  • Homebrew (macOS): Install from `brew.sh`.
    $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • nvm (Node Version Manager): The safest way to install Node.js. It lets you switch between different Node versions easily.
    # Run the install script from the official nvm repo
    $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  • Node.js (via nvm):
    
                                    $ nvm install --lts
                                    $ nvm use --lts
                                
  • Git:
    
                                    # macOS (with Homebrew)
                                    $ brew install git
    
                                    # Ubuntu/Debian
                                    $ sudo apt update && sudo apt install git
                                

In-Class Practical Exercise

Project Scaffolding via CLI

Your task is to create the complete folder and file structure for a new project using only the command line. Do not use your mouse or a graphical file explorer.

The Target Structure:

                    /my-first-app
                    ├── src/
                    │   └── index.js
                    ├── docs/
                    │   └── README.md
                    ├── tests/
                    └── .gitignore
                
  1. From your home directory (`~`), create a `projects` directory if you don't have one, and `cd` into it.
  2. Create the main project folder `my-first-app` and `cd` into it.
  3. Create the `src`, `docs`, and `tests` subdirectories all at once. (Hint: `mkdir` can take multiple arguments).
  4. Create the empty `index.js` file inside the `src` folder using a relative path.
  5. Create the empty `README.md` file inside the `docs` folder.
  6. Create the empty `.gitignore` file in the main project folder.
  7. Finally, use `ls -R` (recursive list) to view your entire directory tree and verify your work.

Final Knowledge Check