Tips・Master the terminal

Terminal basics — the first five commands

The black window feels scary because you can't tell where you are. Learn pwd, ls, cd, and two more, and Git and npm tutorials become something you can simply follow. Includes Windows and Mac differences and the Tab key trick.

The terminal is intimidating because you can’t tell where you are. Fix that—know your location and how to move—and the fear goes. Here are the first five commands, the ones that make Git and npm tutorials followable.

Opening it from VS Code is fastest

From the VS Code menu: Terminal → New Terminal. It opens at the bottom of the editor, and it starts inside the folder you have open, which saves you moving around.

You can also open a standalone app:

  • Mac — Applications → Utilities → Terminal
  • Windows — search the Start menu for “PowerShell” or “Command Prompt”

Whichever you use, the commands here work nearly identically.

Reading the screen

Before you type anything, there’s a line already there. That’s the prompt—the “go ahead” signal.

The bold part is the folder you’re in. Everything right of the % (a > on Windows) is what you type.

The folder you’re currently in is written right there—knowing that alone removes most of the confusion.

The five to learn

CommandWhat it does
pwdPrint where you are
lsList what’s in the current place
cd folder-nameGo into that folder
cd ..Go up one level
clearClean up the screen

pwd — where am I?

pwd
/Users/shima/Documents/my-site

You get an address separated by /. Left is higher up, and each step right goes deeper.

ls — what’s here?

ls
images  index.html  script.js  style.css

Run ls before you move. Confirming the folder exists before you cd into it prevents most failures.

cd — moving around

cd my-site      # go into my-site
cd ..           # go up one level
cd images       # and deeper again

.. is the fixed way to write “one level up.” Stack it to go further: cd ../...

Two habits that remove the pain

Complete names with Tab

Type part of a folder name and press Tab, and the rest fills itself in.

cd my press Tab here
cd my-site/ completed

No more typos—and if nothing completes, that name doesn’t exist, which you learn on the spot. It’s the single most useful key in the terminal.

Drag and drop folders

To reach a deeply nested folder, type cd (with the trailing space) and then drag the folder onto the terminal window. The path is pasted in for you.

Know how to stop things

Some commands, like a development server, keep running. To stop one: Ctrl + C (Ctrl on Mac too, not ⌘).

When the screen “won’t come back,” that’s your first move.

Where Windows and Mac differ

To do thisMac / LinuxWindows (Command Prompt)
List contentslsdir
Show locationpwdcd
Clear the screenclearcls
Movecdcd (same)

PowerShell and Git Bash accept ls and pwd on Windows too. Most tutorials are written for Mac and Linux, so Git Bash makes them easier to copy verbatim.

Git & GitHubInstall Git and set it upGit Bash comes with Git — installation is covered here

A wrong command breaks nothing

Mistyping does no harm; you just get an error message.

  • ↑ key — recalls your previous command, so retyping is quick
  • Read the errorsNo such file or directory means “nothing here by that name”

Summary

  1. Open the terminal from inside VS Code. The folder you’re in is shown in the prompt
  2. Learn pwd, ls, cd, cd .., and clear. Make ls before cd a habit
  3. Tab completion and drag and drop kill typos. Ctrl + C stops what’s running

Once these five feel natural, Git, npm, and WordPress setup guides all become things you can simply follow along.

FAQ

Is the terminal different from the command prompt?
They're the same idea—a screen where you type instructions to your computer. macOS calls it Terminal; Windows has Command Prompt and PowerShell. The terminal inside VS Code does the same job.
Why can't I move into a folder with cd?
Almost always a typo in the folder name, or the folder isn't where you currently are. Run ls to see what's there, then use the Tab key to complete the name.
How do I stop a command that's running?
Ctrl + C (Ctrl on Mac too). It's how you end things like a development server that keeps running.