The terminal is where Linux work gets done. Whether you're managing a cloud server, debugging a Kubernetes pod, or writing a shell script, you'll spend a lot of time here. Learning to move around the terminal efficiently pays dividends across every technical role.
The Shell
When you open a terminal, you're talking to a shell — a program that reads your commands, executes them, and displays results. The most common shell is Bash (Bourne Again Shell). Most Linux distributions use Bash as the default. You'll also encounter zsh (default on macOS), sh (minimal, POSIX-compliant), and fish.
Check which shell you're using:
echo $SHELL
# /bin/bash
Anatomy of a Command
Most Linux commands follow this pattern:
command [options] [arguments]
Example:
ls -la /etc
ls— the command (list directory contents)-la— options:-llong format,-ainclude hidden files/etc— argument: the directory to list
Essential Navigation Commands
pwd # where am I right now?
ls # list current directory
ls -lh /var/log # long listing, human-readable sizes
cd /etc # change to /etc
cd ~ # go home
cd - # go back to previous directory
clear # clear the screen (or Ctrl+L)
Getting Help
Never guess at a command's options — look them up:
man ls # full manual page
ls --help # quick summary of flags
info bash # detailed info pages
whatis curl # one-line description of a command
In man pages: press / to search, n for next result, q to quit.
Pipes and Redirection
The real power of the shell comes from composing commands:
Pipes (|)
Feed the output of one command as input to the next:
ps aux | grep nginx # find nginx processes
cat /var/log/syslog | tail -20 # last 20 lines of syslog
ls /etc | sort | head -10 # first 10 items alphabetically
Redirection
echo "hello" > file.txt # write to file (overwrites)
echo "world" >> file.txt # append to file
cat file.txt # read file
wc -l < file.txt # feed file as input to wc
ls /nonexistent 2> err.txt # redirect errors to file
command > out.txt 2>&1 # redirect both stdout and stderr
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
↑ / ↓ | Navigate command history |
Ctrl+R | Search command history |
Tab | Autocomplete paths and commands |
Ctrl+C | Cancel running command |
Ctrl+Z | Suspend process to background |
Ctrl+L | Clear screen |
Ctrl+A | Move cursor to start of line |
Ctrl+E | Move cursor to end of line |
Ctrl+W | Delete word to the left |
!! | Repeat last command |
sudo !! | Re-run last command as root |
Working with Text in the Terminal
cat file.txt # print file contents
less file.txt # page through file (q to quit)
head -20 file.txt # first 20 lines
tail -f /var/log/syslog # follow log file in real time
grep "error" app.log # search for pattern
grep -r "TODO" ./src/ # recursive search
Environment Variables
The shell uses variables to store configuration:
echo $PATH # directories searched for commands
echo $HOME # your home directory
echo $USER # current username
export MY_VAR="hello" # set a variable for child processes
env # list all environment variables
In the next lesson you'll build on this to create, move, copy, and delete files and directories confidently.