Sysadmin cheat sheet¶
Exercise sysadmin-cheat-sheet-annex.pdf · PDF
A pilot with 10,000 hours of flight still reads a checklist before take-off. Not because she forgot how to fly: because memory fails under pressure.
A system administrator works the same way. At 3 a.m., with a service down and a boss on the phone, nobody remembers whether it was usermod -G or usermod -aG — and the wrong one does damage. Since February you have met dozens of commands: users, passwords, permissions, processes, services, logs, monitoring, configuration. Today you put the ones you forget on one page, in your own handwriting, and you find out what you really know.
What you will learn
- Recall the commands for the most common administration tasks of the unit without looking
- Organise them by task, on one page, with a real example each
- Check a command you are not sure of with
man,--helpor by running it indeb-lab - Find your own weak spots before the exam week
- Why recognising a command is not the same as recalling it
What a good cheat sheet looks like¶
A cheat sheet is a one-page summary of the commands you need, organised so you can find the right one in seconds.
Which of these two helps you at 3 a.m.?
Add joan to the group design (keep his groups) sudo usermod -aG design joan
Make pau change his password at next login sudo chage -d 0 pau
The first one is a dictionary: you must already know the word to look it up. The second one starts from what you want to do. That gives three rules:
| Rule | Why | Bad | Good |
|---|---|---|---|
| Task first, command second | Under pressure you know the problem, not the command | chage — change expiry |
Make pau change his password at next login → sudo chage -d 0 pau |
| A real example | A placeholder hides the order of the arguments | usermod -aG <group> <user> |
sudo usermod -aG dev marta |
| Only what you forget | A sheet you cannot scan in ten seconds is a manual | ls — list files |
usermod -aG — the -a you always forget |
Use the names of Tramuntana Apps — marta, joan, aina, pau, the groups dev, design, admin, the folder /srv/tramuntana — so every line is something you could type tomorrow.
Memory first, then check, then test¶
The Exercise sheet has eight boxes, A to H, one per topic of the unit. You fill them in three steps:
flowchart LR
S1["<b>1 · From memory</b><br>notes closed, pen<br>leave gaps where you forget"] --> S2["<b>2 · Check</b><br>notes, man, --help, deb-lab<br>fill gaps in another colour"]
S2 --> S3["<b>3 · Test</b><br>a neighbour runs one of<br>your lines exactly as written"]
S3 -->|"it fails"| FIX["<b>Fix the line</b>"]
- Step 1 — from memory. Notes closed, VM untouched. Write the tasks and commands you remember. Where you remember the task but not the command, write the task and leave a gap.
- Step 2 — check. Now open the notes,
man,--helpanddeb-lab. Fill the gaps and correct mistakes in another colour. That second colour is the map of what you must study. - Step 3 — test. Swap sheets. Your neighbour picks one line and runs it in
deb-labexactly as you wrote it. If it fails, you fix it.
Why from memory first?
The effort of pulling something out of your memory is what makes it stick. This is called retrieval practice: trying to remember, even when you fail, teaches more than reading the notes again. Reading a command and thinking "yes, I know that one" is recognition. Writing it on a blank page is recall — and recall is what the exam and a 3 a.m. emergency ask for.
Careful: a copied sheet is somebody else's memory
Your neighbour's sheet may look nicer. But the learning happens while you decide what goes on it. Copy it and you have a page of somebody else's memory.
What the boxes can hold¶
After step 1, compare your sheet with this list. It is not a sheet to copy: it shows the kind of line worth having. Keep only the ones you forget, and the pages of this unit explain each of them.
| Box | Lines worth having |
|---|---|
| A · Users, groups | sudo adduser nil · sudo usermod -aG dev nil · id nil · sudo passwd -l nil (lock) · getent group dev · Windows: New-LocalUser, Add-LocalGroupMember |
| B · Passwords, policy | sudo passwd nil · sudo chage -l nil · sudo chage -d 0 nil · sudo chage -M 90 -W 7 nil · sudo chage -E 2027-06-30 nil |
| C · Processes, services | ps aux · top · kill PID, then kill -9 PID · systemctl status name (also start, stop, restart) · sudo systemctl enable --now name · Windows: Get-Process, Get-Service |
| D · Permissions, ACL | chmod 640 file · chmod 2770 dir · sudo chown root:dev dir · getfacl dir · sudo setfacl -m u:aina:rx dir · Windows: icacls |
| E · Configuration | hostnamectl · sudo timedatectl set-timezone Europe/Madrid · echo $PATH · export NAME=value · alias ll='ls -la' in ~/.bashrc |
| F · Logs, monitoring | sudo journalctl -u name · sudo journalctl -b -p err · sudo journalctl -t sudo · uptime · free -h · df -h · vmstat 1 |
| G · Maintenance | Empty for now: you fill it in Maintenance and optimisation (apt clean, apt autoremove, journalctl --vacuum-time, systemd-analyze blame, sfc /scannow) |
| H · Development tools | Empty for now: you fill it in What a development machine needs |
The traps that cost the most points¶
Two lines lose more points than any other, every year. Put them on your sheet with a warning.
| You type | What really happens | What you meant |
|---|---|---|
sudo usermod -G design joan |
joan is removed from every other supplementary group; only design is left |
sudo usermod -aG design joan — -a means append |
sudo systemctl enable backup.service |
It will start at the next boot; it is not running now | sudo systemctl enable --now backup.service — at boot and now |
In short: enable = at boot, start = now, enable --now = both.
The retrieval quiz¶
The back of the Exercise sheet is a quiz of twelve tasks: cheat sheet face down, eight minutes, then you swap and correct. The mark does not count; what counts is the list of questions you missed. Here is the kind of task it asks, with an answer that works (any equivalent command is right):
| Task | One answer |
|---|---|
Add joan to design and keep his other groups |
sudo usermod -aG design joan |
Make pau change his password at next login |
sudo chage -d 0 pau |
rwxr-x--- as three digits |
750 |
Give aina read access to report.txt without changing owner, group or mode |
sudo setfacl -m u:aina:r report.txt |
| Ask process 4321 to finish; it ignores you | kill 4321, then kill -9 4321 |
Read the log messages of backup.service |
sudo journalctl -u backup.service |
| See how much memory a new program can still get | free -h (column available) |
| Delete the package files APT downloaded and installed | sudo apt clean |
Before you leave, mark the box of your sheet with the most gaps after step 1. That is what you revise first.
Key takeaways¶
- A good cheat sheet goes task first, command second, with a real example, and holds only what you forget.
- Build it in three steps: from memory, then check in another colour, then test a line on a real machine.
- Retrieval practice — trying to remember before looking — is what makes commands stick; recognising a command is not recalling it.
- The second colour on your sheet is the map of what to study before the exam.
- The two classic traps:
usermod -Gwithout-adrops the user's other groups;enablewithout--nowdoes not start the service now.
Quick check¶
1. Which line is written the way a cheat sheet should be?
- Make pau change his password at next login → sudo chage -d 0 pau
- chage — change user password expiry information
- chage [options] LOGIN
- Passwords: see the manual page of chage
A cheat sheet starts from the task and gives the exact command with a real example. The other lines are dictionary entries: you must already know the command to use them.
2. You run sudo usermod -G dev marta, without -a. What happens to Marta's other supplementary groups?
- She is removed from them
- Nothing changes in them
- They are renamed to dev
- The command fails and nothing changes
Without -a (append), -G replaces the list of supplementary groups with the one you give. Marta is left only in dev. The safe line is sudo usermod -aG dev marta.
3. You run sudo systemctl enable backup.service and nothing else. Is the service running now?
- No: it will start at the next boot
- Yes: enable starts it at once
- Only for the root user
- Only after running daemon-reload
enable means "start at boot"; start means "now". To get both in one command, use sudo systemctl enable --now backup.service.
4. A service failed last night. Which command shows what it wrote in the log?
-
sudo journalctl -u name -
systemctl enable name -
ps aux -
df -h
journalctl -u filters the journal by unit, so you see only the messages of that service. ps aux lists processes running now, and a failed service is no longer running.
5. Why do you write the sheet from memory before opening your notes?
- The effort of recalling is what makes the commands stick
- It is faster than copying the commands from the notes
- The notes are not allowed during the whole session
- Commands written from memory are always correct
That is retrieval practice. The gaps you leave in step 1 also show exactly what you do not know yet — the second colour of step 2 is your study plan.
6. Aina's sheet has a whole page for ls, cd and pwd, and nothing for chage or setfacl. Select the two that are true.
- It breaks the rule of keeping only what you forget
- The lines for chage and setfacl are the ones worth adding
- The sheet is better because it covers the basics first
- Longer sheets are better because they hold more commands
A cheat sheet holds only what you forget. ls and cd you type every day; chage -d 0 and setfacl -m are the lines you will need and not remember. A sheet you cannot scan in ten seconds is a manual.
Next: fill box G — Maintenance and optimisation.