Skip to content

Operating Systems S1 — Cheatsheet

Summary based on the 2024–2025 course material


Table of Contents


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.

ln original hardlink
ln -s /path/to/target symlink
  • 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

ssh user@server
ssh -p 2222 user@server
scp file user@server:/tmp/
scp -r folder user@server:/tmp/

Key authentication

ssh-keygen -t ed25519
ssh-copy-id user@server
ssh user@server

The private key stays secret; the public key goes on the server in ~/.ssh/authorized_keys.

chmod 700 ~/.ssh
chmod 600 ~/.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

#!/usr/bin/env bash
name="Johan"
echo "Hello $name"
echo "$PATH"
export APP_ENV=production
chmod +x script.sh
./script.sh

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:

name:x:UID:GID:comment:home:shell

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
chmod 2770 shared/            # setgid
chmod 1777 /shared-tmp        # sticky bit

Least privilege

Use sudo for targeted administrative tasks. Working as root increases the impact of every mistake.


Partitions, Filesystems and LVM

lsblk -f
sudo fdisk -l
sudo blkid
df -hT
du -sh /var/*
mount | column -t

Steps for classic storage:

disk → partition table → partition → filesystem → mount point
sudo fdisk /dev/sdb
sudo mkfs.ext4 /dev/sdb1
sudo mkdir -p /data
sudo mount /dev/sdb1 /data

Make permanent mounts via UUID in /etc/fstab and test before rebooting:

UUID=<uuid>  /data  ext4  defaults  0  2
sudo mount -a

LVM

Physical Volume (PV) → Volume Group (VG) → Logical Volume (LV) → filesystem
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

ip address
ip link
ip route
ping -c 4 8.8.8.8
ping -c 4 example.com
ss -tulpn
resolvectl status
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

  1. Create a VM with sufficient CPU, RAM and disk space.
  2. Attach the correct ISO and choose the right firmware/boot order.
  3. Set language, keyboard, timezone, hostname, users and storage.
  4. Install a bootloader and remove the ISO after installation.
  5. Update the system, install guest tools and check network/DNS.
  6. 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

  1. Read the full error message.
  2. Check context: user, current path, permissions and exit code.
  3. Check status and logs.
  4. Test from local to external and from simple to complex.
  5. Change one thing at a time and document the result.