Guide

Linux Reference

Command line, processes, packages, networking, scripting

01
📁
CLI & Navigation
Moving around the filesystem, finding files, reading logs, copying and deleting
Files Paths grep
02
⚙️
Processes & System
Viewing and killing processes, resource usage, logs, permissions
ps aux kill top
03
📦
Package Management
Installing and removing software with apt, flatpak, and snap
apt flatpak snap
04
🌐
Networking
Checking connections, troubleshooting, DNS, ports, and transfers
ip ss curl
05
📜
Shell Scripting
Variables, loops, conditionals, functions, and useful patterns
bash loops aliases
linux-ref / processes-system
Section 02

Processes & System

A process is any running program. Every process has a PID (Process ID) — a unique number the system uses to track and control it. Understanding processes lets you see what's running, why something is slow, and how to stop things that misbehave.

Viewing processes
CommandWhat it does
ps auxSnapshot of all running processes from all users
ps aux | grep steamFilter the process list — find processes matching a name
topLive interactive process viewer, updates every few seconds (q to quit)
htopBetter version of top with colours and mouse support (sudo apt install htop)
pgrep steamList just the PIDs of processes matching a name
ps aux — what the columns mean
ColumnMeaning
USERWho owns the process
PIDProcess ID — the number you use to target it with kill
%CPUCPU usage right now
%MEMMemory (RAM) usage right now
STATProcess state: S = sleeping, R = running, Z = zombie, D = waiting on disk
COMMANDThe actual command being run
Stopping processes
CommandWhat it does
kill PIDAsk a process to stop gracefully (sends SIGTERM)
kill -9 PIDForce-kill a process immediately — use when kill alone doesn't work
pkill steamKill all processes matching a name — no PID needed
pkill -f steamMatch against the full command line, not just the process name
pkill -9 steamForce-kill all matching processes
pkill -f steam && flatpak run com.valvesoftware.SteamKill orphaned Steam processes then relaunch — what fixed it today
Tip: Always try graceful kill before -9. Force-killing can leave lock files or corrupted state behind that causes problems on the next launch.
Background & foreground jobs
CommandWhat it does
command &Run a command in the background — shell stays usable
Ctrl + CStop (interrupt) the foreground process
Ctrl + ZPause the foreground process and send it to the background
jobsList paused/background jobs in the current shell session
fgBring the most recent background job back to the foreground
bgResume a paused job in the background
nohup command &Run in background, keep running even after you close the terminal
Resource information
CommandWhat it does
free -hShow RAM usage in human-readable format (MB/GB)
df -hShow disk space usage for all mounted drives
du -sh folder/Show total size of a specific folder
lscpuCPU info — cores, architecture, speed
lsblkList all storage devices and partitions
lspciList PCI devices (GPU, network card, etc.)
uname -aShow kernel version and system architecture
uptimeHow long the system has been running and current load
System logs
Logs are your first stop when something breaks. Linux stores most logs in /var/log/ and via journald — which is what we used to debug Steam today.
CommandWhat it does
journalctl -xeRecent system journal entries with explanations
journalctl -u servicenameLogs for a specific systemd service
journalctl --since todayOnly show logs from today
tail -f /var/log/syslogWatch the system log live
dmesg | tail -30Kernel messages — useful after hardware changes or crashes
Permissions
Every file has an owner and permission bits controlling who can read (r), write (w), and execute (x) it. ls -la shows these as: -rwxr-xr-- (owner / group / everyone else).
CommandWhat it does
chmod +x script.shMake a file executable
chmod 755 fileOwner: rwx, Group: r-x, Others: r-x
chown james:james fileChange file owner and group
sudo commandRun a command as root — needed for system-level changes
Warning: sudo runs commands as root — the most powerful user on the system. Understand what a command does before running it with sudo.
linux-ref / package-management
Section 03

Package Management

On Kubuntu you have three ways to install software: apt (system packages from Ubuntu repos), flatpak (sandboxed apps from Flathub — like Steam), and snap (Canonical's containerised packages). Each has its use case.

apt — system packages
apt is the main package manager for Ubuntu/Debian-based systems. It installs software into the system directly.
CommandWhat it does
sudo apt updateRefresh the package list from repositories (always do this first)
sudo apt upgradeUpgrade all installed packages to latest versions
sudo apt install packageInstall a package
sudo apt remove packageRemove a package (keeps config files)
sudo apt purge packageRemove a package and its config files
sudo apt autoremoveRemove packages that are no longer needed by anything
apt search keywordSearch for packages by keyword
apt show packageShow details about a package — version, description, dependencies
dpkg -l | grep packageList installed packages matching a name
sudo apt --fix-broken installFix broken package dependencies
Tip: Always run sudo apt update before installing anything. Without it you might install an outdated version or hit dependency errors.
flatpak — sandboxed apps
Flatpak runs apps in a sandbox, isolated from the rest of your system. Steam is installed this way on your machine. Apps come from Flathub.
CommandWhat it does
flatpak listList all installed Flatpak apps
flatpak search appnameSearch Flathub for an app
flatpak install flathub com.app.NameInstall an app from Flathub
flatpak run com.app.NameRun a Flatpak app (note: case-sensitive app ID)
flatpak updateUpdate all installed Flatpak apps
flatpak update com.app.NameUpdate a specific app
flatpak uninstall com.app.NameRemove a Flatpak app
flatpak uninstall --unusedRemove unused runtimes to free disk space
App IDs are case-sensitive: com.valvesoftware.Steam not com.valvesoftware.steam — this is what tripped you up earlier today.
snap — Canonical packages
Snap is another containerised package system from Canonical. It's not installed by default on Kubuntu but can be added. Less common than apt or flatpak for most use cases.
CommandWhat it does
sudo apt install snapdInstall snap support if it's not already there
snap find appnameSearch the Snap Store for an app
sudo snap install appnameInstall a snap package
snap listList installed snaps
sudo snap refreshUpdate all snaps
sudo snap remove appnameRemove a snap
Which one to use?
SituationUse
System tools, libraries, dev tools (python, git, htop, tree)apt
Desktop apps (Steam, browsers, media players)flatpak
App only available as snap and not in apt/flatpaksnap
.deb file downloaded manuallysudo dpkg -i file.deb
linux-ref / networking
Section 04

Networking & Troubleshooting

Linux has a solid set of tools for inspecting network interfaces, checking connections, testing DNS, and transferring files. Especially relevant given your UniFi setup.

Network interfaces & IP addresses
CommandWhat it does
ip aShow all network interfaces and their IP addresses (modern replacement for ifconfig)
ip linkShow link layer info for all interfaces (up/down state, MAC)
ip routeShow the routing table — which interface handles which traffic
ip route show defaultShow just the default gateway
nmcliNetworkManager CLI — manage connections, Wi-Fi, VPNs
nmcli device statusShow all network devices and their connection state
nmcli con showList all saved network connections
Testing connectivity
CommandWhat it does
ping 8.8.8.8Test basic connectivity to an IP address (Ctrl+C to stop)
ping -c 4 google.comSend exactly 4 pings and show results
traceroute google.comShow every hop your traffic takes to reach a destination
mtr google.comLive traceroute with packet loss stats (sudo apt install mtr)
curl -I https://example.comFetch just the HTTP headers from a URL — test if a site is up
wget -q -O /dev/null urlTest download without saving anything — check if URL is reachable
DNS
CommandWhat it does
nslookup google.comSimple DNS lookup — shows what IP a hostname resolves to
dig google.comFull DNS query with detailed response (sudo apt install dnsutils)
dig google.com @1.1.1.1Query a specific DNS server (useful for testing your UniFi DNS filtering)
dig +short google.comJust the answer, no extra output
resolvectl statusShow current DNS configuration per interface
cat /etc/resolv.confShow which DNS servers the system is configured to use
Ports & connections
CommandWhat it does
ss -tulnpList all listening ports and which process owns them (modern replacement for netstat)
ss -tnpShow active TCP connections with process names
ss -sSummary of socket statistics
nc -zv host portTest if a specific port is open on a remote host
ss flags: -t TCP, -u UDP, -l listening only, -n no hostname resolution, -p show process
Downloading & transferring files
CommandWhat it does
curl -O https://url/fileDownload a file keeping its original name
curl -L -o name.file https://urlDownload following redirects, save with a custom name
wget https://url/fileDownload a file (simpler than curl for basic downloads)
scp file.txt user@host:/dest/Securely copy a file to a remote machine over SSH
rsync -avz src/ user@host:/dest/Sync files efficiently — only transfers what changed
Wi-Fi
CommandWhat it does
nmcli device wifi listScan and list available Wi-Fi networks
nmcli device wifi connect "SSID" password "pass"Connect to a Wi-Fi network
iwconfigShow wireless interface info including signal strength
iw dev wlan0 linkShow connection details for a specific wireless interface
linux-ref / shell-scripting
Section 05

Shell Scripting

Shell scripts let you automate repetitive tasks. A script is just a text file with commands — the same ones you type in the terminal — that run in sequence. Bash is the default shell on Kubuntu.

Your first script
Create a file, make it executable, run it. That's the whole workflow.
# Create the file nano myscript.sh # Inside the file — always start with this line: #!/bin/bash echo "Hello, James" # Save and exit nano: Ctrl+O, Enter, Ctrl+X # Make it executable: chmod +x myscript.sh # Run it: ./myscript.sh
#!/bin/bash is called a shebang. It tells the system which interpreter to use. Always put it on the first line of every script.
Variables
# No spaces around the = sign NAME="James" COUNT=5 # Use a variable with $ echo "Hello, $NAME" echo "Count is: ${COUNT}" # braces optional but clearer # Capture command output into a variable TODAY=$(date +%Y-%m-%d) echo "Today is $TODAY" # Special variables echo $0 # Script name echo $1 # First argument passed to the script echo $# # Number of arguments echo $? # Exit code of the last command (0 = success)
Conditionals
# Basic if/else if [ $COUNT -gt 3 ]; then echo "Count is greater than 3" elif [ $COUNT -eq 3 ]; then echo "Count is exactly 3" else echo "Count is less than 3" fi # Comparison operators # -eq equal -ne not equal # -gt greater than -lt less than # -ge >= -le <= # String comparison if [ "$NAME" = "James" ]; then echo "Hi James" fi # Check if a file exists if [ -f /path/to/file ]; then echo "File exists" fi # Check if a directory exists if [ -d /path/to/dir ]; then echo "Directory exists" fi
Loops
# For loop — iterate over a list for item in one two three; do echo "Item: $item" done # For loop — iterate over files for file in /home/james/*.txt; do echo "Found: $file" done # For loop — numeric range for i in {1..5}; do echo "Number: $i" done # While loop COUNT=0 while [ $COUNT -lt 5 ]; do echo "Count: $COUNT" COUNT=$(( COUNT + 1 )) done
Functions
# Define a function greet() { echo "Hello, $1" # $1 is the first argument to the function } # Call it greet "James" greet "world" # Function with return value (via exit code) is_running() { pgrep -f "$1" > /dev/null 2>&1 } if is_running "steam"; then echo "Steam is running" else echo "Steam is not running" fi
Aliases — shortcuts for long commands
Add aliases to ~/.bashrc so they persist across sessions. Run source ~/.bashrc after editing to apply them immediately.
# Open ~/.bashrc nano ~/.bashrc # Add aliases at the bottom: alias steam='pkill -f steam; flatpak run com.valvesoftware.Steam' alias update='sudo apt update && sudo apt upgrade' alias ll='ls -la' alias ports='ss -tulnp' alias myip='ip a | grep inet' # Apply without restarting terminal: source ~/.bashrc
Useful real-world patterns
# Run command, and if it fails run something else ping -c1 google.com && echo "Online" || echo "Offline" # Kill orphaned processes and relaunch (what fixed Steam today) pkill -f steam && flatpak run com.valvesoftware.Steam # Log output of a command to a file with timestamp echo "[$(date)] Starting backup" >> ~/backup.log rsync -av ~/Documents/ /backup/ >> ~/backup.log 2>&1 # Watch a command every 2 seconds (like a live dashboard) watch -n 2 free -h # Find largest files in a directory du -ah /home/james/ | sort -rh | head -20 # Check if a package is installed dpkg -l | grep htop