Getting Started · #5 of 19

The Terminal

Your Command Center

Why the Terminal?

The graphical interface is nice, but the terminal is:


Anatomy of a Command

┌──────────────────────────────────────────┐
│  user@ubuntu:~$ ls -la /home             │
│  └──┬───────┘ └┘ └─┬─┘ └──┬──┘           │
│     │         │    │      │              │
│   prompt   command flags  argument       │
└──────────────────────────────────────────┘

Essential Commands

pwd                 # Print working directory (where am I?)
ls                  # List files and directories
ls -l               # Long format (permissions, size, date)
ls -la              # Include hidden files (starting with .)
cd /path/to/dir     # Change directory
cd ~                # Go to home directory
cd ..               # Go up one level
cd -                # Go to previous directory

Getting Help

man ls              # Manual page for 'ls'
ls --help           # Quick help for 'ls'
whatis ls           # One-line description

Terminal Control

clear               # Clear the screen (or Ctrl + L)
history             # Show command history
exit                # Close terminal

Keyboard Shortcuts

Shortcut Action
Tab Autocomplete command/path
Tab Tab Show all possible completions
↑ / ↓ Navigate command history
Ctrl + C Cancel current command
Ctrl + L Clear screen
Ctrl + R Search command history
Ctrl + A Move cursor to start of line
Ctrl + E Move cursor to end of line
Ctrl + U Delete from cursor to start
Ctrl + K Delete from cursor to end

The Manual (man pages)

Every command has a manual. Press q to exit.

man ls       # How to use 'ls'
man man      # Manual for the manual!

Sections of a man page:


Try It!

Use the terminal below to practice basic commands:

Suggested commands:

Try it in the terminal

A sandboxed shell with this lesson’s commands. Type help to see what’s available.

bash — try it