Why Linux?

Nearly every self-hosted container image, NAS operating system, and home-lab hypervisor runs on Linux. Knowing twenty core commands and how to read service logs turns mysterious errors into quick fixes.
Choosing a Distribution
| Distribution | Best For | Package Manager | Notes |
|---|---|---|---|
| Debian 12 | Headless servers, stability | apt | Predictable releases, low overhead |
| Ubuntu Server 24.04 | General servers, wide tutorials | apt | LTS updates and broad driver support |
| Alpine Linux | Minimal container bases | apk | Tiny footprint (~5MB base image) |
| Proxmox VE | VMs and LXC containers | apt | Debian-based Type-1 hypervisor |
| TrueNAS Scale | Storage + containers | Appliance | ZFS pools with browser admin UI |
| Unraid | Mixed-drive home NAS + VMs | Slackware base | Paid licence, flexible parity array |
| Arch Linux | Desktop learning | pacman | Rolling release, rarely ideal for unattended servers |
Recommended starting point: Debian 12 or Ubuntu Server 24.04 LTS for straightforward Docker compatibility and long security support windows.
Essential Commands
File Operations
ls -la # List files with details and hidden files
cd /path/to/dir # Change directory
pwd # Print working directory
cp file1 file2 # Copy
mv file1 file2 # Move/rename
rm file # Delete (careful: no recycle bin)
rm -rf directory # Delete directory and contents (verify path first)
mkdir -p path/to/dir # Create nested directories
cat file # Display file contents
less file # Page through a file (q to quit)
head -20 file # First 20 lines
tail -20 file # Last 20 lines
tail -f file # Follow file in real-time (great for logs)System Information
uname -a # Kernel and architecture
hostname # Machine name
uptime # Time since last reboot and load averages
free -h # Memory usage
df -h # Disk space usage
du -sh /path # Size of a directory
top / htop # Running processes
lsblk # Block devices (disks, partitions)
ip addr # Network interfaces and IP addresses
ss -tlnp # Listening TCP portsPackage Management (Debian and Ubuntu)
sudo apt update # Refresh package lists
sudo apt upgrade # Upgrade installed packages
sudo apt install <package> # Install a package
sudo apt remove <package> # Remove a package
sudo apt autoremove # Remove unused dependenciesFile Permissions
Linux splits file permissions into three scopes: owner, group, and others.
-rw-r--r-- 1 user group 4096 Mar 15 README.md
│││ │││ │││
│││ │││ └── Others: read only
│││ └──── Group: read only
└────── Owner: read + writeCommon permission commands:
chmod 600 .env # Owner read/write only (secrets)
chmod 644 config.yml # Owner read/write, others read
chmod 755 script.sh # Owner all, others read/execute
chmod -R 755 /data # Recursive
chown user:group file # Change ownership
chown -R 1000:1000 /data # Common for Docker volumesSystemd: Managing Services
Modern Linux distributions manage background daemons through systemd:
sudo systemctl start docker # Start a service
sudo systemctl stop docker # Stop a service
sudo systemctl restart docker # Restart
sudo systemctl enable docker # Start on boot
sudo systemctl disable docker # Don't start on boot
sudo systemctl status docker # Check status
journalctl -u docker -f # Follow service logsCreating a Custom Service
# /etc/systemd/system/myapp.service
[Unit]
Description=My Application
After=network.target
[Service]
Type=simple
User=appuser
WorkingDirectory=/opt/myapp
ExecStart=/opt/myapp/run.sh
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable --now myappSSH: Remote Access
ssh user@server-ip # Connect
ssh -p 2222 user@server-ip # Non-standard port
scp file user@server:/path # Copy file to server
scp user@server:/path file # Copy file from server
rsync -avz /local/ user@server:/remote/ # Sync directoriesSSH Config File
Store aliases in ~/.ssh/config to avoid repeating flags:
Host mynas
HostName 192.0.2.100
User admin
Port 2222
IdentityFile ~/.ssh/id_ed25519
Host docker-server
HostName 192.0.2.101
User deployConnect afterwards with ssh mynas.
Troubleshooting Workflow
Read the Logs
# System logs
journalctl -xe # Recent errors
journalctl --since "1 hour ago" # Last hour
# Docker container logs
docker logs container-name
docker logs -f --tail 50 container-name # Follow last 50 lines
# Application-specific
grep -i error /var/log/syslogCheck Connectivity
ping 8.8.8.8 # Check raw IP routing
ping example.com # Check DNS resolution
curl -I https://example.com # Check HTTP/TLS response
dig yourdomain.com # Inspect DNS records
traceroute 8.8.8.8 # Trace network hops
ss -tlnp # Confirm service ports are listeningCheck Resource Limits
htop # Interactive CPU and RAM viewer
df -h # Check for full filesystems
free -h # Check available RAM and swap
docker stats # Per-container CPU and RAM
iostat # Disk I/O bottlenecksProduct links may include affiliate partnerships. See our affiliate disclosure for details.