Skip to main content

Command Line Basics: Talking to Your Computer

TL;DR: Learn the minimal command line skills you need for real dev work.

Key steps​

  1. Navigate folders and inspect files.
  2. Run scripts and understand exit codes.
  3. Use search tools to find symbols quickly.

Practice​

  • Practice: navigate to a repo and run one command that prints a file list.

In an age of graphical interfaces and AI assistants, the command-line terminal can seem intimidating. But learning a few basic commands is a superpower for any developer. It gives you direct control over your computer and is essential for many development tasks.

Why the Terminal Matters​

  • Direct Control: The terminal is the most direct way to interact with your computer's file system and run scripts.
  • Automation: You can chain commands together to automate repetitive tasks.
  • Required for Tooling: Many development tools, like Git and Node.js, are primarily used through the command line.

Essential Commands​

Here are a few of the most important commands. Don't worry about memorizing them all at once; you'll learn them with practice.

  • pwd (Print Working Directory): Shows you the path of the directory you are currently in.
  • ls (List): Lists the files and folders in the current directory.
  • cd (Change Directory): Used to move into a different directory. For example, cd my-project.
  • mkdir (Make Directory): Creates a new directory. For example, mkdir new-folder.
  • clear: Clears the text from your terminal screen.

(Note: On Windows, the commands are slightly different. dir is used instead of ls, and cd works similarly. PowerShell is the modern Windows command line.)

Running a Script​

Once you have a Python or Node.js script, you can run it from the terminal.

  • Node.js: node my-script.js
  • Python: python my-script.py

This is how you will execute the programs you build.

Ask Your AI Assistant​

The terminal has thousands of commands. If you see one you don't understand, ask your AI!

"Explain this terminal command in a simple way: grep -r "hello world" ."

Your Turn: Get Comfortable​

  1. Open the terminal on your computer (Terminal on Mac/Linux, PowerShell on Windows).
  2. Use pwd to see where you are.
  3. Use ls to see what's there.
  4. Use mkdir to create a new directory called my-first-project.
  5. Use cd to move into that directory.
  6. Create a simple hello.js file in that directory and run it using node hello.js.

Congratulations! You're now using the command line.