Lab 03 · Beginner to Early Intermediate · 35–45 min · Linux Fundamentals
Almost every server, every cloud machine and every security tool runs on Linux. This lab teaches you to move around it, read it, inspect it and lock it down — from the command line, the way professionals do.
Mission Brief
Learn the Linux command line well enough to navigate a real system, inspect it, and protect a folder with the right permissions — then prove it in a simulated terminal mission.
pwd, ls, cd, cat, touch, mkdir, cp, mv, rmwhoami, id, uname, ps, topchmodPrerequisites: Labs 01 and 02 (the labs unlock in order). What you need: this page and a browser. Everything in this lab uses a fictional training system — no real commands run anywhere, and nothing here touches your own computer.
Module 1
Linux runs most of the internet’s servers, most cloud machines, and most security tools. It is free, open source, and built around the command line — which is exactly why cybersecurity professionals live in it.
bash. When you type ls, it is the shell that finds and runs the ls program.When a command runs, the shell asks the kernel to do the work, the kernel talks to the hardware, and the result comes back up the chain to your screen. Every module in this lab is one part of that chain.
Why the command line? A graphical interface shows you what someone else decided you need. The command line shows you everything — every file, every process, every permission — and it can be scripted, so a task you do once can be repeated a thousand times. That is why servers usually have no desktop at all.
Module 2
Linux has one filesystem tree, starting at the root directory /. Everything — your files, the system’s files, even devices — lives somewhere under it. Click any directory in the map below to see what it is for. This is the same fictional filesystem you will work in during the challenge.
Each directory has one job. Click one to see its purpose here.
Three commands cover almost all navigation:
pwd
/home/learner
ls
documents downloads mission
cd mission
pwd
/home/learner/mission
pwd — “print working directory”. Tells you where you are right now.ls — lists what is inside the current directory. ls -l shows the long format: permissions, owner, size and date.cd — “change directory”. cd mission moves into mission; cd .. moves up one level; cd alone takes you home; cd / takes you to the root./home/learner/mission. It works from anywhere, because it spells out the whole route./home/learner, cd mission is enough. From anywhere else, it fails — there is no mission there.. means “this directory” and .. means “the parent directory”. cd ../documents goes up one level, then into documents.Common mistake: typing cd /mission when you mean cd mission. The leading slash changes everything — it tells the shell to look at the root of the filesystem, not inside your current folder. If you get “No such file or directory”, check whether your path starts with a slash it should not have.
Module 3
Once you can move around, you can work with files. Every command below is one verb — learn the verb, and the rest is practice.
| Command | What it does | Safe example |
|---|---|---|
cat | Prints a file’s contents to the screen. | cat notes.txt |
less | Opens a file page by page, for long files. | less /var/log/messages |
touch | Creates an empty file (or updates its timestamp). | touch draft.txt |
mkdir | Creates a directory. | mkdir vault |
cp | Copies a file: cp source destination. | cp notes.txt notes-backup.txt |
mv | Moves or renames a file. | mv draft.txt final.txt |
rm | Deletes a file. Permanent — there is no recycle bin. | rm draft.txt |
cat is for reading, less is for reading long files without flooding the screen (press q to quit less). cp keeps the original and makes a second copy; mv moves it, so the original location ends up empty. And mv is also how you rename things — moving a file to a new name in the same folder.
Respect rm. Deleted files do not go to a trash folder — they are gone. rm -rf deletes a folder and everything inside it without asking. Professionals check the path twice before pressing Enter, and they never run rm on a path they have not read. In this lab’s training terminal, rm is disabled on purpose — deleting is the one thing a practice environment should never let you do by accident.
Module 4
Before you change anything on a system, you look at it. These five commands answer the first questions a professional asks: who am I, what machine is this, and what is running on it?
| Command | What it answers | Example output |
|---|---|---|
whoami | Which user am I logged in as? | learner |
id | What are my user ID, group ID and groups? | uid=1000(learner) gid=1000(learner) groups=1000(learner) |
uname | What system is this? | Linux htp-lab 6.8.0-htp x86_64 GNU/Linux |
ps | Which processes are running? | See below |
top | What is using CPU and memory right now? | See below |
Every user has a number (UID) and belongs to a group (GID). root is UID 0 — the administrator, who can do anything. Normal users start at UID 1000. id shows all of it at once, which is why it matters for permissions in the next module: a file’s owner and group decide who may touch it.
A process is a running program. Every process has a number (PID). ps lists the ones running now:
PID TTY TIME CMD
1 ? 00:00:02 systemd
412 ? 00:00:00 sshd
638 pts/0 00:00:00 bash
901 pts/0 00:00:00 ps
top shows the same picture live, sorted by CPU usage, refreshing every few seconds — press q to quit it:
top - 01:30:00 up 2 days, 1 user, load average: 0.12, 0.08, 0.05
Tasks: 84 total, 1 running, 83 sleeping, 0 stopped, 0 zombie
%Cpu(s): 1.2 us, 0.8 sy, 0.0 ni, 98.0 id, 0.0 wa, 0.0 hi, 0.0 si
MiB Mem : 3934.2 total, 2871.5 free, 412.3 used, 650.4 buff/cache
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
638 learner 20 0 12340 5120 3400 S 0.3 0.1 0:00.04 bash
Defender’s habit: when something feels wrong on a system, the first checks are ps and top. A process you do not recognise — a strange name, a program running from a temp folder, a process eating CPU at 3 AM — is the kind of thing that starts an investigation. Knowing what normal looks like is what makes abnormal visible.
Module 5
Every file and folder has permissions: who may read it, who may write to it, and who may execute it. Permissions are the first line of defence on a Linux system — they decide what a stolen password or a compromised program can actually reach.
Permissions are set for three groups of people:
Each of the three groups gets three permissions, each worth a number:
| Permission | Value | On a file | On a folder |
|---|---|---|---|
r — read | 4 | Read the file’s contents | List what is inside |
w — write | 2 | Change or delete the file | Create or delete files inside |
x — execute | 1 | Run the file as a program | Enter the folder (cd into it) |
Add the values to get the number: read (4) + write (2) = 6; read + write + execute (4 + 2 + 1) = 7; nothing = 0. Three digits — owner, group, others — describe the whole file. That is why you see numbers like 755 and 644 everywhere.
Toggle the permissions below and watch the symbolic and numeric forms change together.
Owner can read and write; group can read; others can read.
| Mode | Symbolic | Use it for |
|---|---|---|
755 | rwxr-xr-x | Folders and public programs — everyone can enter and read, only the owner can change. |
644 | rw-r--r-- | Ordinary files — everyone can read, only the owner can change. |
700 | rwx------ | Private folders — only the owner can enter. Your .ssh folder uses this. |
600 | rw------- | Private files — only the owner can read or write. SSH private keys use this. |
To change permissions you use chmod — chmod 700 vault sets a folder to owner-only, chmod 644 notes.txt makes a file readable by everyone but changeable only by you. You will use exactly this in the challenge.
The 777 trap. When something does not work, the lazy fix is chmod 777 — everyone can do everything, so the error goes away. So does your security: any user, any program, any attacker who gets in can now read, change and delete that file. A permission error is the system doing its job. Fix the permission, not the warning.
Module 6
Every command has the same shape. Learn the shape once, and every new command you meet will look familiar. Click each part:
Command, option, argument — and the output that comes back. Click one to see what it does.
Real work is a sequence of small commands, each doing one thing. The mission in this lab is exactly that — a recipe of five steps:
pwd
cd mission
ls
cat flag.txt
mkdir vault
chmod 700 vault
ls -l
Each line is one command, and each one only makes sense after the one before it: you check where you are, move to the right folder, look inside it, read the file, create the folder, lock it down, and verify the result. That is command-line thinking — not memorising commands, but chaining small, exact steps into a job done properly.
On a real system you can also chain commands with && — mkdir vault && chmod 700 vault runs the second command only if the first one succeeds. The training terminal runs one command at a time, so practise the steps separately here; the habit of checking each step before the next is the skill that transfers.
Knowledge Check
Six questions. You need 4 out of 6 to pass and earn 30 XP. Every answer explains itself — right or wrong.
Practical Challenge
You are logged in to a fictional training system as user learner, starting in /home/learner. This is a real working terminal simulation — it keeps state: directories you create stay created, permissions you change stay changed. Nothing here runs on a real system, and only the commands in help are allowed. Complete all seven objectives:
pwd.Todo/home/learner/mission.Todoflag.txt.Todocat flag.txt and read the code inside.Todovault inside the mission folder.Todochmod 700 vault.Todols -l and confirm vault shows drwx------.Todo0 of 7 complete. Type help in the terminal if you are unsure where to start.
Your progress in the terminal is checked live during this visit. Your overall lab completion is saved on your device. Resetting the terminal restores the fictional filesystem and clears your mission progress — use it if you get stuck.
Debrief
The mission, solved step by step:
pwd
/home/learner
cd mission
ls
flag.txt notes.txt
cat flag.txt
HTP-LAB3-FLAG-7K2Q9
mkdir vault
chmod 700 vault
ls -l
drwx------ 2 learner learner 4096 Nov 21 01:30 vault
-rw-r--r-- 1 learner learner 84 Nov 21 01:30 flag.txt
-rw-r--r-- 1 learner learner 96 Nov 21 01:30 notes.txt
cd /mission instead of cd mission — the leading slash sends you to the root, where no mission folder exists. Relative paths start from where you are.cat flag.txt from the wrong folder — the file lives in mission. If cat says “No such file”, check pwd first.chmod before mkdir — you cannot change the permissions of a folder that does not exist yet. Create first, protect second.chmod and assuming it worked is not a check. ls -l showing drwx------ is the proof.Permissions are the cheapest defence in computing. A private key at 600 cannot be read by another user even if they get onto the same machine; an .ssh folder at 700 cannot be entered at all. The vault you just built is the same idea: the owner has full access, everyone else has nothing. Attackers love misconfigured permissions — world-writable folders, private keys left at 644, web roots at 777 — because the system itself hands them the keys.
ls -l first, chmod second, ls -l again to verify.777 to “fix” a permission error — find out who actually needs access and grant exactly that./tmp, strange processes in ps, and world-writable files are the first things a defender looks for.Terminal and shell basics · Filesystem navigation and paths · File operations · System inspection (whoami, id, uname, ps, top) · Permission model and chmod · Verifying your own work before calling it done.
Complete the quiz and the challenge to finish this lab.
Completing this lab earns the “Terminal Operator” achievement — and if you have finished all three labs, “Field Ready” too. Your recommended next step is the Ethical Hacking: From Basics to Advanced course on the main site, which builds directly on everything these three labs taught. This preview only demonstrates the recommendation — course access itself is unchanged: hackthepalnte.co.uk/resources.