Linux — Level by Level›01 · Your first terminal session

Lesson 01 of 19 · Level 1 — Beginner: everyday commands

Your first terminal session

Get a Linux machine to practise on, understand what the terminal and shell are, and learn the habits that make every later lesson easier: reading the prompt, getting help, tab completion and history.

Beginner
Key wordsterminalshellbashpromptmantab completionhistory

Why Linux first

Every container, Kubernetes node, cloud VM and network appliance you'll ever manage runs Linux. When a pod is stuck, a disk is full or a node is slow, the answer is found in Linux, not in a dashboard. This track takes you from your very first command to kernel tuning and hardening.

A computer normally talks to you with pictures and buttons. The terminal is like texting the computer instead: you type a short instruction, and it texts back. It feels strange at first, but it's much faster, and you can save your messages as a recipe (a script) to replay any time.

Get a Linux machine to practise on

Any of these works:

Option Good for
A cloud VM (free tiers exist) The most realistic: a real server
Multipass / VirtualBox VM on your laptop Offline practice, easy to rebuild
WSL2 on Windows Quick start on a Windows laptop
A container: docker run -it --rm ubuntu:24.04 bash Instant, but no systemd, so services lessons won't work

We'll use Ubuntu in examples; the Red Hat family (RHEL, Rocky, Alma) differs mainly in the package manager (dnf instead of apt), which we'll point out.

Terminal, shell, prompt

  • The terminal is the window.
  • The shell is the program inside it that reads your commands. Usually bash; zsh is common on macOS.
  • The prompt tells you who and where you are:
asha@web-01:~/projects$
│    │      │         └─ $ = normal user (# = root, be careful)
│    │      └─ current directory (~ = your home directory)
│    └─ machine (hostname)
└─ user

Your first commands

$ whoami
asha
$ hostname
web-01
$ pwd
/home/asha
$ cat /etc/os-release | head -3
PRETTY_NAME="Ubuntu 24.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
$ uname -r
6.8.0-45-generic

Every command follows the same shape:

command  -options  arguments
ls       -l -a     /etc

Options change how it runs (usually starting with - or --); arguments say what to run it on.

Getting help without Google

$ man ls          # full manual. Space = next page, / = search, q = quit
$ ls --help       # short summary
$ type cd         # cd is a shell builtin
cd is a shell builtin

The manual pages are written for the version installed on your machine, which makes them more reliable than a random web answer.

Habits that save hours

  • Tab completion: type cat /etc/os-r then Tab. Press Tab twice to list the choices when there are several. It saves typing and typos.
  • History: ↑ for the previous command; Ctrl+R to search ("reverse-i-search"). history lists everything.
  • Cancel: Ctrl+C stops the running command. Ctrl+D ends input (and logs you out of a shell).
  • Clear: Ctrl+L.

Copy and paste

In most terminals, Ctrl+Shift+C / Ctrl+Shift+V copy and paste (Ctrl+C is taken for "cancel"). On macOS it's Cmd+C / Cmd+V.

Try it: a guided tour

  1. Find out your username, hostname, distribution and kernel version.
  2. Open man man and find out what section 5 of the manual is for. Quit with q.
  3. Type ls /usr/b and press Tab. Then ls /usr/ and Tab Tab.
  4. Run five commands, then press Ctrl+R and find the first one again by typing part of it.
  5. Run sleep 100, then stop it with Ctrl+C.

Going deeper: the shell is a program too

  • echo $SHELL shows your login shell, and ps -p $$ shows the shell you're actually in.
  • Your shell reads start-up files (~/.bashrc for interactive bash shells). That's where aliases and prompt settings go, and where "it works in my terminal but not in cron" bugs start (see Bash Scripting).
  • Add a timestamp to history (HISTTIMEFORMAT='%F %T ') on servers. When investigating an incident, "who ran what, when" matters.

Recap

  • Terminal = window, shell = interpreter (bash), prompt = who@where, and $ vs #.
  • Commands are command -options arguments.
  • Help is built in: man, --help, type.
  • Tab, ↑, Ctrl+R and Ctrl+C are the habits that make everything faster.

This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.