Meet the terminal
Time to demystify the black window with green text. The terminal is where the real power lives, and after this lesson you'll be unafraid of it.
What the terminal actually is
A terminal is a program that takes typed commands, sends them to the OS, and shows you the result. That's it. Every hacking tool you'll ever use is either a terminal command or a program controlled from one.
When you open a terminal, you meet a prompt — a short bit of text telling you who you are and where you are:
kali@kali:~$
kali(before@) — your username.kali(after@) — the computer's name (hostname).~— where you are (~is shorthand for your home folder).$— you're a normal user. (#means you're root, the admin.)
Your first command
Type this and press Enter:
whoami
The terminal replies with your username. You just ran a command and got a result. That's the whole rhythm.
Try a few more:
pwd # "print working directory" — shows where you are
ls # "list" — shows files here
date # today's date and time
uname -a # full info about the OS you're on
Anatomy of a command
Every command follows the same shape:
command option(s) argument(s)
↑ ↑ ↑
what to do how on what
Example:
ls -l /etc
# | | |
# | | +-- the folder to list (argument)
# | +------- long format (option / flag)
# +----------- the command itself
Environment variables and PATH — how the shell finds commands
When you type ls, the shell doesn't magically know where the ls program lives on disk — it searches a specific list of folders stored in an environment variable called PATH:
echo $PATH
# /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
The shell checks each folder in that list, in order, until it finds a program matching what you typed. This matters for security in a genuinely concrete way: PATH hijacking (referenced in Path 16's Windows privesc lab, and its Linux equivalent) exploits exactly this lookup mechanism — if an attacker can place a malicious file with the same name as a legitimate command somewhere earlier in the PATH search order, the shell runs the attacker's version instead, without you or the calling program necessarily noticing. Environment variables generally (viewable with env or printenv) store all kinds of configuration the shell and programs read — your default text editor, your home directory location, and dozens of other settings.
Which shell am I even using?
bash is this course's default assumption, but you'll also encounter zsh (macOS's modern default), sh (a minimal, older shell many scripts target for maximum compatibility), and others. Check which one you're currently in with echo $SHELL or ps -p $$. The core commands in this lesson work identically across nearly all of them — the differences mostly show up in scripting syntax and interactive features (autocompletion styles, prompt customization), which won't trip you up at this stage.
Getting help — the two most important commands
You will forget things. Every professional does. There are two universal ways to look things up:
man ls # the full manual for ls (press q to quit)
ls --help # a shorter usage summary
man (short for "manual") is a mini book on every command. Use it constantly. When you finish this lesson, man man gets meta and reads you the manual on the manual system.
Real hackers spend a huge amount of time reading man pages and searching. Being lost is normal — being able to find the answer efficiently is the skill.
Command history — you type less than you think
- ↑ and ↓ arrow keys — cycle through previous commands.
- Ctrl+R then type a few characters — search backwards through history.
history— see the last commands you ran.!42— re-run command #42 from history.!!— re-run the previous command (great withsudo:sudo !!re-runs the last one as root).
Tab completion — your best friend
Press Tab while typing a command or filename and the terminal completes it for you. Press Tab twice to see all matches. This saves enormous amounts of typing and prevents typos.
Try:
cd /et<Tab> # completes to /etc/
ls /us<Tab>/bin/ba<Tab> # completes to /usr/bin/bash
Changing password (do this now)
Remember the default Kali password? Change it:
passwd
You'll be asked for the current password, then a new one twice. Choose something strong — this VM will hold your notes, tools, and eventually possibly bug bounty info.
Editing text — pick your poison
You'll edit files constantly. Pick one editor now and get comfortable:
nano— friendliest for beginners. Commands shown at the bottom of the screen. Save with Ctrl+O, quit with Ctrl+X.vim— the classic. Steeper learning curve but ubiquitous. Typevimtutorfor a 30-minute tutorial that pays for itself for life.- VS Code — graphical, if you install it later.
Try nano now:
nano hello.txt
# Type something, then Ctrl+O to save, Enter to confirm, Ctrl+X to quit.
cat hello.txt # show its contents
The three streams
Every command has three "streams":
- stdin (0) — input, usually from the keyboard.
- stdout (1) — normal output, usually to the screen.
- stderr (2) — errors, usually also to the screen.
You'll redirect these in the next lesson to build pipelines. For now, know they exist.
Comfort keys
| Key | What it does |
|---|---|
| Ctrl+C | Cancel the running command |
| Ctrl+D | Signal end-of-input / logout |
| Ctrl+L | Clear the screen (or clear) |
| Ctrl+A | Jump cursor to start of line |
| Ctrl+E | Jump cursor to end of line |
| Ctrl+U | Delete from cursor to start |
| Ctrl+W | Delete previous word |
| Ctrl+R | Reverse-search history |
Memorise these five: Ctrl+C, Ctrl+L, Ctrl+A, Ctrl+E, Ctrl+R. They're used constantly.
🧪 Lab — Warm up in the terminal
Open a terminal in Kali and run each of these. Read what happens.
whoami
pwd
ls
ls -la
date
uname -a
cal
echo "Hello from Kali"
history
man ls
# (press q to quit man)
Then try:
mkdir kashsec-notes # make a folder
cd kashsec-notes # move into it
touch first-note.txt # create an empty file
nano first-note.txt # write something, save with Ctrl+O, exit with Ctrl+X
cat first-note.txt # print its contents
cd .. # go back up
You've just navigated, created, edited, and read a file entirely from the keyboard. This is how everything in this course now works.
Which command shows the full manual for another command? And how do you exit it?
Show answer
man <command>. Exit by pressing q.Key terms
- Terminal / shell — the text interface for typing commands.
- Prompt — the
user@host:path$line waiting for input. - Command / option / argument — the three parts of any command.
man— the built-in manual.- stdin / stdout / stderr — the three input/output streams.
- Tab completion / history — the two habits that make the terminal fast.
Recap
- The terminal is just a place to type commands and see results.
- Every command has a shape:
command options arguments. manand--helpare your permanent lookup tools.- Tab completion and
Ctrl+Rhistory search cut typing dramatically. - Change your default Kali password with
passwd.
References
- Linux Journey — command line basics — beautifully paced walk-through.
- ExplainShell — paste any command, get every flag explained.
- tldr pages — friendlier, example-first alternative to
man. - OverTheWire Bandit levels 0–10 — game-style practice.
Next up → The Linux Filesystem Hierarchy