Skip to content
6 min read·Lesson 4 of 10

Working with the Terminal

Get comfortable with the Linux terminal — the shell, essential commands, shortcuts, and how to compose powerful one-liners.

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: -l long format, -a include 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

ShortcutAction
↑ / ↓Navigate command history
Ctrl+RSearch command history
TabAutocomplete paths and commands
Ctrl+CCancel running command
Ctrl+ZSuspend process to background
Ctrl+LClear screen
Ctrl+AMove cursor to start of line
Ctrl+EMove cursor to end of line
Ctrl+WDelete 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.

Key Takeaways

  • The terminal (shell) is the primary interface for administering Linux systems.
  • Bash is the most common shell; zsh and fish are popular alternatives.
  • Pipes (|) and redirects (>, >>, <) let you chain commands and work with files efficiently.
  • Command history (↑), tab completion, and Ctrl shortcuts dramatically speed up your workflow.
  • man <command> and --help show you how any command works.

Test your knowledge

Try exam-style practice questions to reinforce what you've learned.

Practice Questions →