The Terminal
Chapter 11 — Essential Terminal Skills
You've seen terminal commands throughout this course — for updating software, changing settings, and fixing problems. Now it's time to understand the terminal properly. This chapter covers exactly what you need to be capable at the command line: reading the prompt, navigating the file system, working with files and folders, using sudo safely, and editing text files. You won't become a shell scripter from this chapter, but you'll be able to follow any guide online and handle most everyday tasks confidently.
1. Opening a Terminal
Every Linux desktop has a terminal emulator — an application that gives you a command-line interface. The fastest ways to open one:
- Ubuntu (GNOME) — press
Ctrl+Alt+T, or search for "Terminal" in the Activities overview - Linux Mint (Cinnamon) — press
Ctrl+Alt+T, or right-click the desktop → "Open Terminal Here" - KDE Plasma — press
Ctrl+Alt+T(if configured), or search for "Konsole" in the application launcher - XFCE — right-click the desktop → "Open Terminal Here", or find "Terminal Emulator" in the application menu
- Any desktop — search "terminal" in the application launcher; every desktop has one installed
2. Reading the Prompt
When you open a terminal you see a prompt — a line indicating the shell is ready for input. It looks something like this:
- username — the account you're logged in as
- hostname — the name of the computer (from Chapter 6)
- current directory — where in the file system you are right now.
The tilde (
~) is shorthand for your home directory (/home/philip) - $ symbol — means you're a normal user. A # symbol means you're root (the administrator). You should almost never see # in normal use.
Type a command after the prompt and press Enter to run it. The output appears on the lines below, then a new prompt appears when the command finishes.
3. The Linux File System
Linux has one unified file system tree starting at / (called "root" or "slash"). There are no drive letters like Windows — everything, including additional drives and USB sticks, appears as a folder somewhere under /.
The most important location for day-to-day use is your home directory. Everything you
create and most software configuration lives under /home/yourusername/,
abbreviated to ~ in the prompt and in commands.
.bashrc,
.config/, .ssh/. They are hidden by default in the file manager
and in ls output. Press Ctrl+H in the file manager to show them,
or use ls -a in the terminal.
4. Navigating the File System
5. Working with Files and Folders
rm a file it is gone immediately. Be especially careful with rm -r
(recursive delete) — a typo can delete far more than you intended. Always double-check
the path before pressing Enter. Never run rm -rf / or rm -rf ~
— these would destroy your entire system or home directory respectively.
6. Viewing File Contents
less, not cat, for large files.
cat dumps everything to the screen at once — on a 10,000-line log file
you'll see thousands of lines fly past. less lets you scroll at your own pace.
Inside less: /searchterm to search, n for next match,
q to quit.
7. sudo — Running Commands as Administrator
Many system tasks — installing software, editing system files, restarting services — require administrator privileges. Linux uses sudo (superuser do) to grant temporary elevated permissions for a single command.
- When typing your sudo password, nothing appears on screen — no dots, no asterisks. This is normal; keep typing and press Enter.
- Only your own account (or other accounts in the
sudogroup) can use sudo — this protects the system from other users. - Copy-pasting sudo commands from the internet can be dangerous. Read what a command does before running it with sudo.
- If you get "philip is not in the sudoers file", your account needs to be added to the sudo group — ask Chapter 6's user management section.
8. Editing Files with nano
nano is the friendliest terminal text editor — it shows keyboard shortcuts at the bottom of the screen so you don't need to memorise anything to get started. It's available on virtually every Linux system and is what most guides recommend for beginners.
Inside nano, the bottom two lines show the available commands. The ^ symbol
means the Ctrl key:
9. Terminal Shortcuts That Save Time
| Shortcut | What it does |
|---|---|
| Tab | Auto-complete file/folder names and commands. Press twice to show all matches. Use it constantly. |
| ↑ / ↓ | Scroll through command history. Find and re-run a previous command without retyping it. |
| Ctrl+R | Reverse search through command history. Start typing a word from a previous command to find it. |
| Ctrl+C | Cancel (stop) the currently running command. Press this when a command hangs or you change your mind. |
| Ctrl+L | Clear the screen (same as the clear command). Keeps your command history. |
| Ctrl+A | Jump to the beginning of the current command line. |
| Ctrl+E | Jump to the end of the current command line. |
| Ctrl+U | Delete everything from the cursor to the beginning of the line. Quick way to clear a command. |
| Ctrl+W | Delete the word immediately before the cursor. |
| Ctrl+D | Exit the shell / close the terminal (like typing exit). |
| Ctrl+Shift+C | Copy selected text from the terminal (not Ctrl+C — that cancels the command!). |
| Ctrl+Shift+V | Paste into the terminal. |
10. Pipes and Redirection
Two features of the shell that you'll encounter in guides and find genuinely useful:
The pipe — |
A pipe sends the output of one command as the input to another. This lets you chain commands together to filter or process output.
Output redirection — > and >>
Instead of printing output to the screen, redirect it to a file.
11. A Few More Useful Commands
uname -rShow current kernel versionuptimeHow long the system has been runningdf -hDisk usage — how full each partition isfree -hRAM usage — total, used, availabletopLive view of running processes and CPU/RAM use. Press q to quit.htopNicer version of top (install with apt if missing)find ~ -name "*.txt"Find all .txt files in your home directorygrep -r "word" ~/DocumentsSearch for "word" inside files recursivelywhich firefoxFind where a command/program is installedman lsShow the manual page for any command. Press q to quit.ls --helpQuick help for a command (faster than man)sudo systemctl status nginxCheck if a service is runningsudo systemctl restart nginxRestart a servicesudo systemctl enable nginxStart a service automatically on bootkill 1234Stop a process by its PID numberkillall firefoxStop all processes named firefoxchmod +x script.shMake a file executablechmod 644 file.txtrw-r--r-- (owner write, others read)chown philip file.txtChange file owner to philipls -lShow permissions for files in current directorysudo apt install commandname). "No such file or
directory" means you've typed a path that doesn't exist — check spelling and case
(Linux filenames are case-sensitive).
Chapter Summary
| Skill | Key commands |
|---|---|
| Navigate | pwd (where am I), ls (list files), cd folder (enter folder), cd .. (go up), cd ~ (go home) |
| Files & folders | mkdir (create dir), touch (create file), cp (copy), mv (move/rename), rm (delete — permanent!) |
| View files | cat (print), less (page by page), head/tail (first/last lines), grep (search inside) |
| Admin | sudo command — runs command as administrator. Password cached for ~15 minutes. Nothing shows when typing the password. |
| Edit files | nano filename — Ctrl+O to save, Ctrl+X to exit, Ctrl+W to search. |
| Shortcuts | Tab (complete), ↑↓ (history), Ctrl+C (cancel), Ctrl+L (clear), Ctrl+R (search history) |
| Pipes | cmd1 | cmd2 — send output of cmd1 to cmd2. > file — redirect output to file. >> file — append to file. |
| Get help | man command — full manual. command --help — quick reference. Error messages usually tell you exactly what went wrong. |