DEV Community

RexTora
RexTora

Posted on

Day 02: The Terminal, Shells & File Systems

🎯 Learning Objectives

  • Understand the interface boundary between Terminal Emulators and Shell Interpreters (including Windows Terminal vs. PowerShell vs. CMD).

  • Master File System path tracking, hidden dotfiles, and essential CLI utilities.

  • Map system execution paths via global and local environment configurations.

1. Terminal vs. Shell (The Windows Architecture)

  • Terminal: The visual GUI wrapper. A window application that captures keyboard strokes, handles GPU text rendering, and manages tabs/panes.

    • Examples: Windows Terminal, iTerm2, Alacritty.
  • Shell: The command interpreter engine running inside the terminal. It evaluates text strings, processes scripts, issues system calls (syscalls), and interacts with the OS Kernel.

    • Examples: PowerShell, Bash, Zsh, Command Prompt (CMD).
┌────────────────────────────────────────────────────────┐
│ WINDOWS TERMINAL GUI (The Visual Interface Window)     │
│  │                                                     │
│  ├───► Tab 1: [ PowerShell Core Engine (Modern) ]       │
│  ├───► Tab 2: [ Command Prompt Engine  (Legacy) ]       │
│  └───► Tab 3: [ WSL Ubuntu Linux Bash  (Core) ]         │
└───────────────────────────┬────────────────────────────┘
                            │ Raw Text & Input Streams
                            ▼
┌────────────────────────────────────────────────────────┐
│ SHELL INTERPRETER (e.g., PowerShell / CMD)             │
│  └───► Parses input string commands into system tasks  │
└───────────────────────────┬────────────────────────────┘
                            │ System Call (Syscall)
                            ▼
┌────────────────────────────────────────────────────────┐
│ OPERATING SYSTEM KERNEL                                │
│  └───► Interacts directly with underlying hardware     │
└────────────────────────────────────────────────────────┘
Enter fullscreen mode Exit fullscreen mode

2. Deep Dive: PowerShell vs. Command Prompt (CMD)

While both are Windows shells hosted inside Windows Terminal, they belong to entirely different computing eras:

  • Command Prompt (cmd.exe): A legacy text shell maintained purely for backwards compatibility with 1980s MS-DOS. It pipelines data as Plain Text Only, meaning outputs must be manually string-filtered.

  • PowerShell (pwsh.exe): A modern, cross-platform scripting engine. It pipelines data as Objects, allowing developers to directly read structural properties (e.g., file size, permissions) without parsing raw text.

[ CMD APPROACH (Text Parsing Stream) ]
`dir` ──► Outputs text characters ──► Requires complex string filters to read metadata.

[ POWERSHELL APPROACH (Object Oriented) ]
`Get-ChildItem` ──► Outputs File Objects ──► Programmatically query: file.Size, file.Extension
Enter fullscreen mode Exit fullscreen mode

3. File System Navigation & Hidden Layers

  • Root (/ or C:\): The absolute origin of the system storage hierarchy.

  • Absolute Path: Complete address starting directly from the system root.

    • Example: C:\var\www\rextora\src\server.js
  • Relative Path: Conditional paths computed dynamically based on your current working location.

    • Example: ../config/.env (moves up one directory level, then steps into the config folder).
  • Hidden Files (Dotfiles): Administrative configuration layers starting with a period (.). The OS restricts them from standard folder views by default to safeguard configuration states.

    • Examples: .env, .gitignore, .profile.
               [ C:\ ]  (SYSTEM ROOT)
                  │
         ┌────────┴────────┐
       /bin              /var
                           │
                         /www
                           │
                       /rextora  ◄── [ Absolute Start ]
                           │
                  ┌────────┴────────┐
                /src             /config
                  │                 │
             server.js            .env  ◄── [ Hidden File ]
                  ▲                 ▲
                  │                 │
                  └────( ../ )──────┘   ◄── [ Relative Step ]
Enter fullscreen mode Exit fullscreen mode

4. Command Line Interface (CLI) Fundamentals

Direct textual manipulation of storage resources and active processes, completely bypassing graphical interfaces. These are the core commands a developer must know:

  • pwd ──► Prints your current location: Displays the exact absolute path of the folder you are currently working inside.

  • ls (or dir on Windows) ──► Lists directory contents: Scans and shows all files and folders contained within your current path.

  • cd ──► Changes your directory: Moves your terminal's active focus forward into a target folder or backward (cd ..) to a parent folder.

  • mkdir ──► Creates a new folder: Instantly allocates a brand-new, empty directory sector on your storage drive.

  • touch (or New-Item on Windows) ──► Creates a blank file: Drops a new empty file pointer (like app.js or .env) directly into your current directory.

  • cat ──► Views file contents: Prints the raw text inside a file directly onto your screen without launching an external text editor.

  • rm ──► Permanently deletes files/folders: Erases target files instantly, bypassing the recycle bin completely (rm -rf forcefully purges entire folder branches).

       [ Command Input ] ──► `mkdir -p src/api`
               │
               ▼
┌───────────────────────────────┐
│ DISK ALLOCATION               │
│   Storage Sector Partitioned  │
│   └── src/                    │
│       └── api/                │
└──────────────┬────────────────┘
               │
               ▼
       [ Next Command ]  ──► `touch src/api/index.js` (Creates empty file pointer)
Enter fullscreen mode Exit fullscreen mode

5. Environment Variables & The $PATH Variable

  • Environment Variables: Global key-value pairs allocated inside RAM, enabling running applications to fetch setup states (like database credentials) cleanly outside source code files.

    • Real .env Example:

      Ini, TOML

      PORT=5000
      DB_URL="mongodb://localhost:27017/rextora"
      JWT_SECRET="supersecretkey123"
      
  • The $PATH Variable: A specialized system environment variable containing a colon-delimited string list of absolute directories where executable tool binaries live.

    • Real $PATH Example (Linux/Mac):

      Bash

      /usr/local/bin:/usr/bin:/bin:/opt/homebrew/bin
      
    • The Breakdown:

      • /usr/local/bin: Where user-installed third-party tools live.
      • /usr/bin: Standard system executables managed by the OS.
      • /bin: Essential basic system utilities (like ls, cp, mkdir).
      • /opt/homebrew/bin: Mac Homebrew installation binaries.
┌─────────────────────────────────────────────────────────────────────────────┐
│ RAM ENVIRONMENT MEMORY BUFFER                                               │
│                                                                             │
│  ├── PORT=5000                                                              │
│  ├── DB_URL="mongodb://localhost..."                                        │
│  └── $PATH / Path Array:                                                    │
│      [ /usr/local/bin ] ──► [ /usr/bin ] ──► [ /bin ] ──► [ /opt/homebrew ] │
└─────────────────────────────────────────────────────────────────────────────┘
Enter fullscreen mode Exit fullscreen mode
  • Execution Rule: When you run a command like node, the shell loops through every folder in your $PATH array sequentially looking for node.exe. If the tool path is absent from the list, the shell drops a "command not found" / "not recognized as an internal or external command" exception.

📊 Visual Blueprint (Command Path Lookup)

  [ USER TYPES COMMAND ] ──► e.g., "node app.js"
            │
            ▼
  [ SHELL INTERPOLATION ] ──► Shell parses input text.
            │
            ▼
  [ PATH DIRECTORY SCAN ] ──► Scans folders listed inside global Path:
            │
            ├───► Check 1: /usr/local/bin  ──► [ Not Found ]
            ├───► Check 2: /usr/bin        ──► [ FOUND EXECUTABLE! ]
            └───► Skip remaining paths.
            │
            ▼
  [ KERNEL EXECUTION ] ──► Shell hands the executable binary to the OS Kernel.
Enter fullscreen mode Exit fullscreen mode

✅ Key Takeaways

Decoupled Runtimes: Terminal applications manage user interface styling; shell platforms evaluate code execution and issue system hooks.

Modern Shell Rule: CMD is legacy infrastructure. Rely strictly on PowerShell Core or Linux Bash for modern engineering workflows.

Binary Mapping: Applications are unreachable by standard command calls unless their parent directory is securely mapped inside the system's global $PATH.

🏎️ Quick Review: Terminal, Shells & File Systems

  • Terminal vs Shell: Visual wrapper environment (Windows Terminal) vs. logic parser interfaces (PowerShell, CMD, Bash).

  • CMD vs. PowerShell: Legacy text-based stream pipeline vs. modern object-oriented pipeline.

  • Paths: Absolute starts tracking directly from root (/ or C:\); relative calculates offsets from where your terminal window is working right now.

  • Bin Lookups: The shell queries the systematic $PATH variable map to safely trace and wake up program files stored across the hard drive.

🎯 30-Second "Elevator Pitch" Definitions

  • Terminal vs. Shell: "The terminal is the monitor screen frame; the shell is the text engine processing logic inside that frame."

  • CMD vs. PowerShell: "CMD is a typewriter pushing raw text lines; PowerShell is a conveyor belt transporting rich data objects."

  • The $PATH Variable: "An internal lookup sheet telling your shell exactly which system directory folders to check to find and wake up command executables."

Top comments (0)