This cheat sheet collects the commands you will reach for most when running a Linux VPS, grouped by task. Each section links to a full guide when you need more than a one-liner. Commands that change the system need sudo.
Before you start
Files and folders
| Command | What it does |
|---|
pwd | Show the current folder |
ls -lah | List files with sizes, owners and hidden files |
cd /var/www | Change folder |
mkdir -p a/b | Create nested folders |
cp -a src dst | Copy, keeping permissions |
mv old new | Move or rename |
rm -r folder | Delete a folder (no undo) |
cat / less file | Print or page through a file |
tail -f file.log | Follow a log live |
grep -rn "text" /etc | Search inside files |
find / -name "*.conf" | Find files by name |
Users and permissions
| Command | What it does |
|---|
whoami / id | Current user and groups |
sudo adduser name | Add a user (Ubuntu/Debian) |
sudo usermod -aG sudo name | Add to sudo group (wheel on AlmaLinux) |
chmod 644 file | Set permissions |
chown user:group file | Change owner |
passwd | Change your password |
More: Linux file permissions, add a user.
Processes and services
| Command | What it does |
|---|
top / htop | Live CPU and memory per process |
ps aux --sort=-%mem | head | Top memory users |
kill PID / kill -9 PID | Stop a process / force it |
systemctl status nginx | Service status |
sudo systemctl restart nginx | Restart a service |
journalctl -u nginx -f | Follow service logs |
More: systemctl and journalctl, monitor server resources.
Disk and memory
| Command | What it does |
|---|
df -h | Free space per filesystem |
du -sh * | Size of each item here |
ncdu / | Browse disk usage |
free -h | RAM and swap usage |
lsblk -f | Disks, partitions and filesystems |
More: df, du and ncdu.
Networking
| Command | What it does |
|---|
ip a | IP addresses |
ss -tulpn | Listening ports and programs |
ping -c 4 host | Basic reachability |
curl -I https://example.com | Fetch HTTP headers |
dig example.com | DNS lookup |
Firewalls and port rules are covered in Linux firewall comparison and check open ports.
Packages and system
| Command | What it does |
|---|
sudo apt update && sudo apt upgrade | Update Ubuntu/Debian |
sudo dnf upgrade | Update AlmaLinux/Rocky |
uname -r | Running kernel |
cat /etc/os-release | Distro and version |
uptime | Uptime and load average |
sudo reboot | Reboot |
Archives and transfers
| Command | What it does |
|---|
tar -czf site.tar.gz folder | Create a compressed archive |
tar -xzf site.tar.gz | Extract it |
scp file user@host:/path | Copy a file over SSH |
rsync -avz src/ user@host:/dst/ | Sync folders over SSH |
Danger: Commands like rm -rf, chmod -R 777 or dd can destroy a server in seconds. Read the command twice before pressing Enter.
Next steps