Linux and the command line 101
Hands-on Linux for network engineers: find your way around the filesystem, read and edit files, build pipelines with grep, fix permissions, stop a runaway process, log in with SSH keys, write two small Bash scripts, and troubleshoot a web service with ip, ss, curl, dig, traceroute and tcpdump. In your browser, nothing to install.
First lab here? Meet the lab shows how every lab works, once.
Networking 101 showed you how networks work, and its hands-on lab had you type your first commands. This lab is about the place you type them: the Linux command line. It’s where every other lab on this site happens, from Ansible to NetBox to ANTA. It’s also what’s underneath most network gear today, CapeOS included.
You work on a real Linux computer, the codespace itself, and on a small network next to it.
The machines
your codespace ─ ─ ─ management network 172.80.102.0/24 ─ ─ ─ ws1, srv1, r1
ws1 ─────────────── r1 ─────────────── srv1
192.168.10.10/24 .10.1 │ .20.1 192.168.20.10/24
| Name | What it is | Chapters |
|---|---|---|
| codespace | the computer you’re typing on: Debian 12, user vscode, with sudo | all of them |
| ws1 | a Linux workstation: Debian 13, user netops, password netops-lab | 4, 6, 8 |
| srv1 | a Linux server with a small web service on port 8080, and the lab’s DNS server | 6, 8 |
| r1 | the router between them: CapeOS Bolt, user admin, password capeos-lab | 6, 8 |
The passwords are for these lab machines only: they exist inside your codespace and nowhere else. The
management network is how your codespace reaches all three by name (ssh ws1). ws1 and srv1 talk to each
other the way real computers do, through r1.
How each task works
The same five parts as the lessons in Networking 101: explain, show, follow along, challenge,
then check. You answer some questions in answers/<task>.yml, write a few scripts in scripts/, and change
real things: files, permissions, ~/.bashrc, ~/.ssh. make check looks at all of it. The pipelines and
scripts you write are run again on files they haven’t seen, so a command that only works on the example won’t
pass.
Most of chapters 1 to 7 happen in your codespace’s own terminal, not on a lab machine: the terminal in the lab app’s VS Code tab. Open one with Ctrl+`; it starts in the lab’s folder.
Quick start
- Open the lab and sign in with GitHub. The lab is your own copy, in a codespace on your GitHub account's free allowance (what that means). The first start takes a few minutes; coming back takes about one.
- The lab opens in your browser: this guide on the left, VS Code on the right, and the network's state at the top. Wait for it to say network up.
- Follow task 1.1. Check task, under the guide, tells you when you've got it right.
Finished? Finish lab, top right, deletes the codespace. Left it open? It stops itself after 20 minutes without activity, and Open the lab picks up where you were.
Advanced: run it on your laptop Docker, Git and VS Code
$ git clone https://gitlab.com/networkdoodles-labs/linux-cli-101.git
$ cd linux-cli-101
$ code . # then: Reopen in Container
$ make check T=1.1Same dev container, on your own Docker (4 GB of memory is plenty). No dev container? Linux with Docker, containerlab, Python 3 and make runs it with make up, but the tasks assume a Debian user called vscode.
8 chapters · 17 tasks
- 1.1
Where am I?Find out where a new terminal puts you, where your home folder is, which Linux you’re on, and what’s in the lab’s
files/folder, hidden files included. Then use a command’s own help to find an option. - 1.2
PathsFind a config file in a small tree of sites and racks, write its absolute path, then reach it with relative paths from two other folders, using
..to climb up.
- 2.1
Read and writeRead a real router log with
less,headandtail, search it, watch a file grow withtail -f, then write a note in your home folder with nano. - 2.2
Tidy upCount files with
find, then tidy a messy folder of config backups: make folders, rename the file with a space in its name, delete the empty ones, and move the rest with globs.
- 3.1
PipelinesAnswer questions about r1’s log with one line each: count with
grep -c, filter withgrepandgrep -v, count per interface withcut | sort | uniq -c | sort -rn, and send output to a file with>. - 3.2 Who's knocking?From r1’s log, count the failed logins, list them per user name, most first, and list every name that failed, once each. One pipeline each, that works on logs it hasn’t seen.
- 4.1
Who may do whatRead the permissions in
ls -l, find a file only root can read, usesudo, set permissions withchmod, and install a missing tool withapt. - 4.2
Too open, too closedThree files with the wrong permissions: a private key ssh refuses to use, a script that won’t run, and a notes file anyone can change. Read what each error says, and fix each with
chmod.
- 5.1
Jobs and variablesRun a command in the background, pause and resume it, find it with
psandtop; then set an environment variable, see which programs inherit it, and make it last with~/.bashrc. - 5.2
RunawayA process is eating a whole CPU and ignores a polite
kill. Find it, stop it for good. Then make a command of your own that runs from any folder, by putting its folder on your PATH.
- 6.1
Your first keyLog in to ws1 over SSH with a password, and check its host key before you trust it. Then make a key pair of your own, put the public half on ws1 with
ssh-copy-id, and log in with no password at all. - 6.2
Short names, a copy, a changed keyGive ws1, srv1 and r1 short names in
~/.ssh/config, copy a file to srv1 withscp, then meet the warning every engineer meets one day: the host key has changed. Find out why, and fix it the right way.
- 7.1
Is everyone up?Finish
scripts/reach.sh: a script that reads a list of hosts, pings each one, printsupordown, and exits 1 when any of them is down, so other scripts and pipelines can tell. - 7.2
Audit the configsWrite
scripts/audit.shfrom scratch: list the configs in a folder that have nontp serverline, exit 1 if there are any, and handle the cases that break most first scripts: names with spaces, an empty folder, and no folder at all.
- 8.1
Where does it go?Log in to ws1 and work out how it reaches srv1: its addresses and management interface, its gateway, the DNS server it asks and what it answers, the route for one address with
ip route get, and the hops withtraceroute. - 8.2
Refusedsrv1’s web service works when you ask it from srv1, but ws1 gets connection refused. Find out why with
curl -vandss -tlnp, fix the service’s config withsudo nano, restart it, and prove it from ws1. - 8.3
Catch it on the wireCapture one web request from ws1 to srv1 with
tcpdump, save it to a file, read it back, and copy it to the codespace withscp, ready for Wireshark. Read the handshake, the request and the close from the capture.