Linux - there is no place like ~/
Linux - powerful, flexible, and reliable operating system
Linux is a versatile and powerful open-source operating system. Linux’s flexibility, security, and community support make it a popular choice for a wide range of applications. Its open-source nature ensures continuous improvement and adaptation to new technologies and user needs.
Learn it properly on a Raspberry Pi
Reading about Linux gets you surprisingly far and then stops working. At some point you need a machine you own, can break, and can put back - and a Raspberry Pi is the cheapest one that behaves exactly like the servers you will meet later. It runs Debian. You have root. Everything below is the same on a Pi as on a cloud VM.
The best part is that it is genuinely disposable. There is no state on it you cannot recreate, so you can be reckless in a way you never can be on your laptop. Break it, reflash the card, start again in three minutes.
Start headless - no monitor, no keyboard
Use Raspberry Pi Imager, and before writing the card open the settings (the cog icon) to set a hostname, create your user, and enable SSH. Then:
ssh pi@raspberrypi.local
This matters more than it looks. Working over SSH from the start means you learn Linux the way it is actually used on servers - as a text interface - rather than as a desktop that happens to have a terminal.
Where everything lives
The filesystem is not arbitrary; it is a convention every Linux machine shares. Learn this map once and you can find your way around any of them.
/
├── boot/firmware/ config.txt, cmdline.txt <- Pi only
├── etc/ all system-wide config
│ ├── fstab what gets mounted where
│ ├── hostname what this machine calls itself
│ └── systemd/system/ your own services live here
├── home/pi/ your stuff. the ~ in ~/
├── usr/bin/ programs apt installed
├── var/
│ ├── log/ logs
│ └── lib/ state that services keep
├── tmp/ wiped on reboot
├── proc/ NOT real files - live kernel state
└── sys/ NOT real files - hardware
└── class/thermal/thermal_zone0/temp
Two of those are worth dwelling on. /proc and /sys are not files on a disk at all - they are the kernel presenting live state as though it were a filesystem. That is why cat /sys/class/thermal/thermal_zone0/temp gives you the CPU temperature right now, and it is a good demonstration of the "everything is a file" idea people repeat without showing.
Permissions
This is the concept that trips up everyone arriving from Windows or macOS, and it is the cause of most Permission denied messages. Run ls -l and read the first column:
-rwxr-xr-- 1 pi pi 2048 Aug 1 09:14 backup.sh
│└┬┘└┬┘└┬┘ │ │
│ │ │ │ │ │
│ │ │ │ │ └──── the group that owns it
│ │ │ │ │
│ │ │ │ └──────── the user that owns it
│ │ │ │
│ │ │ └────────────── others: r-- read
│ │ │
│ │ └───────────────── group: r-x read + execute
│ │
│ └──────────────────── owner: rwx read + write + execute
│
└────────────────────── type: - file d directory l link
Three groups of three: what the owner may do, what the group may do, what everyone else may do. r read, w write, x execute - and on a directory, x means "may enter".
chmod +x backup.sh # make it executable
chmod 644 notes.txt # owner rw, everyone else read
sudo chown pi:pi myfile # change who owns it
The numbers are the same three groups in binary: read is 4, write is 2, execute is 1, so 644 is rw- r-- r--. Once that clicks it stops being memorisation.
Installing things
Debian-based systems use apt. You are not downloading installers from websites here - you are asking a curated repository:
sudo apt update # refresh the catalogue only
sudo apt full-upgrade # actually upgrade what is installed
sudo apt install htop # install something
apt search thermal # find something
sudo apt autoremove # clean up orphaned dependencies
apt update followed by apt full-upgrade is the one two-step people get wrong: the first only updates the list of what is available.
Run your own service
This is the payoff, and the thing that makes a Pi feel like a real server. systemd starts, supervises and restarts programs - it is what keeps SSH running, and it will do the same for your code.
A trivial program to supervise:
# /home/pi/templog.py
import time
while True:
with open("/sys/class/thermal/thermal_zone0/temp") as f:
print(f"cpu {int(f.read()) / 1000:.1f}C", flush=True)
time.sleep(60)
Describe it to systemd in /etc/systemd/system/templog.service:
[Unit]
Description=Log the Pi CPU temperature
After=network.target
[Service]
Type=simple
User=pi
ExecStart=/usr/bin/python3 /home/pi/templog.py
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Then:
sudo systemctl daemon-reload
sudo systemctl enable --now templog
systemctl status templog # is it alive?
journalctl -u templog -f # follow its output live
Note what you got for free: it starts on boot (enable), it restarts if it crashes (Restart=on-failure), and its print output is captured and searchable without you writing any logging code. Reboot the Pi and it comes back on its own.
Seeing what the machine is doing
| Command | Answers |
|---|---|
htop | What is using CPU and memory right now |
df -h | Am I out of disk space |
free -h | Am I out of RAM, and am I swapping |
journalctl -u <service> -f | What is this service saying |
journalctl -b -p err | What went wrong since boot |
dmesg | tail | What the kernel thinks, including USB and power |
ss -tulpn | What is listening on which port |
The Pi-specific bits
Everything above is ordinary Linux. These four are not:
# menu for Pi settings: interfaces, boot, locale
sudo raspi-config
vcgencmd measure_temp # CPU temperature
vcgencmd get_throttled # 0x0 is good; anything else is
# power or heat trouble
# boot-time hardware config, read before Linux starts
sudo nano /boot/firmware/config.txt
config.txt is read by the firmware before Linux starts - it is where you enable interfaces, set overclocks and configure displays. It has no equivalent on a normal PC, and it is the one file where a typo means the Pi will not boot.
Gotchas
- Never just pull the power. Linux buffers writes. Use
sudo poweroffand wait for the LED. Yanking the cable is the main cause of "my SD card corrupted". - The default user is not
piany more. Modern images make you create one in Imager. Old tutorials assumingpi/raspberryare stale - and that default password was removed for good reason. sudois passwordless by default on Raspberry Pi OS. Convenient on your desk, alarming if the Pi is reachable from the internet. If you expose it, set a password and use SSH keys rather than passwords.- SD cards wear out from logging. If the Pi runs anything chatty, cap the journal (
SystemMaxUse=50Min/etc/systemd/journald.conf) or boot from an SSD. - Learn
manbefore you learn to search.man systemd.serviceis more accurate than most of what you will find online, and it is already on the machine.

