Operating Systems S1 — Cheatsheet
Summary based on the 2024–2025 course material
Table of Contents
- Computer Architecture
- Linux and the Filesystem
- Text Commands, Redirection and Pipes
- SSH, Archives and Compression
- Processes, Jobs and Environment
- Users and Permissions
- Partitions, Filesystems and LVM
- Networking
- Installing Linux
Computer Architecture
| Component | Function | Watch out for |
|---|---|---|
| CPU | Executes instructions | Socket must match the motherboard |
| RAM | Fast, volatile working memory | Type, speed and capacity must be supported |
| Motherboard | Connects all components | Socket, chipset, form factor and expansion slots |
| SSD/HDD | Persistent storage | NVMe is generally faster than SATA |
| GPU | Image processing and parallel computation | Power, size and PSU capacity |
| PSU | Supplies DC power | Enough wattage, correct connectors and a quality margin |
| Cooling | Removes heat | Must fit the socket, case and TDP |
A good build starts from the purpose, the budget and the desired lifespan. Check compatibility and leave room for expansion; an expensive CPU with a too-weak GPU or PSU is not a balanced system.
Sizing
Don't choose purely on peak performance. Reliability, power consumption, cooling, expandability and total cost matter just as much.
Linux and the Filesystem
Linux uses a single hierarchical directory tree with / as the root.
| Path | Meaning |
|---|---|
/home |
Personal directories |
/root |
Home of root |
/etc |
System configuration |
/var |
Variable data such as logs and caches |
/tmp |
Temporary files |
/bin, /usr/bin |
Programs |
/dev |
Devices as files |
/proc, /sys |
Virtual info about the kernel and hardware |
/mnt, /media |
Mount points |
pwd # current directory
ls -lah # list, including hidden files
cd /etc # absolute path
cd ../.. # relative path
mkdir -p project/data # directories including parents
touch file.txt
cp -r source dest
mv old new
rm file.txt
find /var/log -type f -name '*.log'
file somefile
| Symbol | Meaning |
|---|---|
. |
current directory |
.. |
parent directory |
~ |
home directory |
* |
zero or more characters |
? |
exactly one character |
[abc] |
one character from the set |
Deleting
rm has no recycle bin. Check the path and wildcard before rm -r or rm -f.
Links
- Hard link: an extra name for the same inode; usually not across filesystems.
- Symbolic link: contains a path and can point to directories or another filesystem; can become broken.
Text Commands, Redirection and Pipes
cat file.txt
less file.txt
head -n 10 file.txt
tail -f /var/log/syslog
wc -l file.txt
sort file.txt | uniq -c
cut -d: -f1 /etc/passwd
grep -iE 'error|warning' app.log
tr 'a-z' 'A-Z'
| Operator | Behavior |
|---|---|
> |
overwrite stdout |
>> |
append stdout |
2> |
overwrite stderr |
2>&1 |
send stderr to the same destination as stdout |
< |
stdin from a file |
\| |
stdout of the left side becomes stdin of the right side |
grep -i 'failed' /var/log/auth.log | sort | uniq -c > failed.txt
command >output.log 2>error.log
command >all.log 2>&1
A pipe is a data stream
A pipe passes text/data along, not the name of a file. Each command must produce the output the next command expects.
SSH, Archives and Compression
Key authentication
The private key stays secret; the public key goes on the server in ~/.ssh/authorized_keys.
tar and compression
tar -cvf archive.tar folder/ # create
tar -tvf archive.tar # list
tar -xvf archive.tar # extract
tar -czvf archive.tar.gz folder/ # gzip
tar -cjvf archive.tar.bz2 folder/ # bzip2
tar -cJvf archive.tar.xz folder/ # xz
tar bundles files; gzip/bzip2/xz compress the bundle.
Processes, Jobs and Environment
ps aux
pgrep -a ssh
top # interactive process overview
command & # background process
jobs
fg %1
bg %1
kill PID # SIGTERM: stop gracefully
kill -9 PID # SIGKILL: last resort
| Concept | Meaning |
|---|---|
| Program/binary | Executable file on disk |
| Process | Active instance with a PID |
| Parent/child | A process that starts another process |
| Foreground | Uses the current terminal |
| Background | Terminal stays available |
Scripts and variables
Use double quotes around expansions ("$file") to safely handle spaces and wildcards. $? holds the exit code of the previous command: 0 means success.
Users and Permissions
id
whoami
getent passwd user
sudo useradd -m alice
sudo passwd alice
sudo usermod -aG developers alice
sudo groupadd developers
sudo userdel -r alice
A line in /etc/passwd contains:
Password hashes are kept protected in /etc/shadow.
rwx permissions
| Permission | File | Directory |
|---|---|---|
r (4) |
read contents | list names |
w (2) |
modify contents | create/remove entries |
x (1) |
execute | enter/traverse the directory |
ls -l file
chmod 640 file # owner rw, group r, others nothing
chmod u+x script.sh
chown alice:developers file
umask 027
Special bits
| Bit | Effect |
|---|---|
| setuid | process uses the effective UID of the file owner |
| setgid | new files inherit the group on a directory |
| sticky bit | only the owner/root may remove their own entries |
Least privilege
Use sudo for targeted administrative tasks. Working as root increases the impact of every mistake.
Partitions, Filesystems and LVM
Steps for classic storage:
Make permanent mounts via UUID in /etc/fstab and test before rebooting:
LVM
sudo pvcreate /dev/sdb1
sudo vgcreate vgdata /dev/sdb1
sudo lvcreate -L 10G -n lvdata vgdata
sudo mkfs.ext4 /dev/vgdata/lvdata
sudo lvextend -L +5G -r /dev/vgdata/lvdata
pvs; vgs; lvs
-r also grows the filesystem along with the logical volume. Without that step, the extra space stays unusable to the filesystem.
Networking
| Test | If this fails |
|---|---|
ping 127.0.0.1 |
local TCP/IP stack |
ping own-IP |
interface/configuration |
ping gateway |
local network/VLAN |
ping 8.8.8.8 |
routing/internet |
ping example.com |
DNS, if the IP does work |
A host configuration needs at minimum an IP address/prefix, a default gateway and a DNS server. A /24 corresponds to mask 255.255.255.0.
Installing Linux
- Create a VM with sufficient CPU, RAM and disk space.
- Attach the correct ISO and choose the right firmware/boot order.
- Set language, keyboard, timezone, hostname, users and storage.
- Install a bootloader and remove the ISO after installation.
- Update the system, install guest tools and check network/DNS.
- Only take a snapshot once the base installation is correct and clean.
sudo apt update && sudo apt upgrade # Debian/Ubuntu
sudo dnf upgrade # Fedora/RHEL family
hostnamectl
timedatectl
Quick troubleshooting approach
- Read the full error message.
- Check context: user, current path, permissions and exit code.
- Check status and logs.
- Test from local to external and from simple to complex.
- Change one thing at a time and document the result.