What is the terminal?
The terminal (also called the command line, console or shell) is a text-based way to control your computer. Instead of clicking icons, you type commands.
It looks old-fashioned, but it's one of the most powerful tools a developer has:
- Speed: rename 500 files, search every file in a project, or set up a server in seconds.
- Automation: anything you type can be saved as a script and repeated forever.
- Servers: most of the internet runs on Linux servers with no graphical interface at all.
- Developer tools: Git, npm, pip, Docker, cloud CLIs and testing tools all run in the terminal.
Terminal vs shell
- The terminal is the window app: Terminal or iTerm2 on Mac, Windows Terminal, GNOME Terminal on Linux.
- The shell is the program inside it that reads your commands and runs them: bash, zsh (the default on macOS), fish, or PowerShell on Windows.
This track teaches bash/zsh commands, the standard on Linux, macOS and servers. On Windows, use WSL (Windows Subsystem for Linux) or Git Bash to follow along exactly.
Opening a terminal
| OS | How |
|---|---|
| macOS | Press ⌘ + Space, type "Terminal", press Enter |
| Windows | Install WSL (wsl --install in PowerShell as admin) and open "Ubuntu", or use Git Bash |
| Linux | Ctrl + Alt + T |
Anatomy of the prompt and a command
you@learn:~$ ls -l Documents
└┬┘ └─┬─┘ │ │ └┬┘ └┬┘ └───┬───┘
user host │ │ cmd flag argument
│ └─ $ means "ready for a command" (# means you're the admin/root user)
└─ current folder (~ = your home folder)- A command is the program to run:
ls. - Flags (options) change its behaviour:
-lmeans "long format". - Arguments say what to act on:
Documents.
Try it: your built-in terminal
This is a simulated Linux terminal with a sample home folder. Press ▶ Run, then type your own commands in the prompt at the bottom. Press ↑ to repeat earlier commands.
| Command | Does |
|---|---|
whoami |
Prints your user name |
pwd |
Print Working Directory: where you are |
ls |
List the files in the current folder (folders shown with /) |
date |
Shows the date and time |
echo |
Prints text |
clear |
Clears the screen (or press Ctrl + L) |
Getting help
man <command>opens the manual. In a real terminal, press q to quit it.- Most commands also accept
--help. - Type
helpin this simulator to list everything it supports.
Keyboard shortcuts that save hours
| Keys | Action |
|---|---|
| Tab | Auto-complete file and command names (press twice to see options) |
| ↑ / ↓ | Previous / next command from history |
| Ctrl + C | Stop the running command |
| Ctrl + L | Clear the screen |
| Ctrl + A / Ctrl + E | Jump to the start / end of the line |
| Ctrl + R | Search your command history |
Tab completion is the #1 habit of fast terminal users. Type the first few letters and press Tab. It's faster and prevents typos.
Is the terminal dangerous?
Commands run immediately, with no confirmation and no recycle bin. A few rules keep you safe:
- Read a command before pressing Enter, especially anything you copied from the internet.
- Be extra careful with
rm(delete) andsudo(run as administrator). - If something is running and you want it to stop, press Ctrl + C.
In this simulator you can't break anything. Experiment freely!
Practice
In the terminal above, find out: your user name, which folder you start in, and what's inside it. Then print a message with your name using echo.
1.What does pwd do?
2.In ls -l Documents, what is -l?