VPS SSH Commands Cheat Sheet
Linux VPS (Ubuntu Server) + Docker + n8n + Backups + OS Updates
2. System Monitoring
| Command | Description |
|---|---|
top | Live process monitor (CPU, RAM, processes). |
htop | Improved process monitor (if installed). |
free -h | Show RAM usage in human-readable format. |
df -h | Show disk usage for all mounted filesystems. |
du -sh /path | Show total size of folder /path. |
uptime | Show system uptime and load averages. |
who | Show logged-in users. |
3. Service Management (systemd)
| Command | Description |
|---|---|
systemctl status service | Show status of a service (e.g. nginx, docker). |
systemctl restart service | Restart a service. |
systemctl stop service | Stop a service. |
systemctl start service | Start a service. |
journalctl -u service -f | Follow live logs for a service. |
4. Docker Core Commands
| Command | Description |
|---|---|
docker ps | List running containers. |
docker ps -a | List all containers (including stopped). |
docker logs container -f | Follow logs of a container (replace container with name/ID). |
docker restart container | Restart a container. |
docker stop container | Stop a container. |
docker rm container | Remove a stopped container. |
docker images | List Docker images. |
docker rmi image | Remove an image. |
5. Docker & n8n Update Commands
Assuming you run n8n via Docker Compose.
| Command | Description |
|---|---|
docker pull n8nio/n8n | Download the latest n8n image. |
docker compose down | Stop the n8n stack (from the folder with docker-compose.yml). |
docker compose up -d | Start the n8n stack in the background with the new image. |
docker pull image | Update any Docker image (replace image with name). |
docker system prune -a | Remove unused containers, networks, and images (careful). |
Safe pattern: backup n8n data → pull new image → docker compose down → docker compose up -d.
6. OS Update Commands (Ubuntu Server)
| Command | Description |
|---|---|
apt update | Refresh package list from repositories. |
apt upgrade -y | Install available package updates. |
apt dist-upgrade -y | Perform a more complete upgrade (may change dependencies). |
apt autoremove -y | Remove unused packages and dependencies. |
reboot | Reboot the VPS (often needed after kernel updates). |
uname -r | Show current kernel version. |
Best practice: take a VPS snapshot in your provider panel before running major OS upgrades.
7. Backup Commands (Files & Folders)
| Command | Description |
|---|---|
cp -r /source /backup/ | Copy folder /source recursively to /backup/. |
tar -czvf backup.tar.gz /folder | Create a compressed backup archive of /folder. |
tar -xzvf backup.tar.gz | Extract a compressed backup archive. |
rsync -av /source /destination | Sync /source to /destination (great for backups). |
Tip: use /backup or another dedicated folder for storing backup archives.
8. n8n Backup Commands
Protect workflows, credentials, and executions. Adjust paths to your actual n8n data directory.
| Command | Description |
|---|---|
cp -r ~/.n8n /root/n8n-backup/ |
Backup n8n data folder to /root/n8n-backup/ (or another safe location). |
tar -czvf n8n-backup.tar.gz ~/.n8n |
Create a compressed backup of the n8n data folder. |
docker exec n8n n8n export:workflow --all |
Export all n8n workflows from inside the n8n container. |
docker exec n8n n8n export:credentials --all |
Export all n8n credentials from inside the n8n container. |
Pattern: before updating n8n or Docker, backup the n8n data folder and optionally export workflows/credentials.
9. Database Backup Commands
Only needed if you use an external database (PostgreSQL/MySQL) for n8n or other apps.
| Command | Description |
|---|---|
pg_dump dbname > backup.sql | Backup a PostgreSQL database named dbname to backup.sql. |
mysqldump -u root -p dbname > backup.sql | Backup a MySQL database named dbname (will prompt for password). |
gzip backup.sql | Compress the SQL backup file. |
10. Network & Connectivity
| Command | Description |
|---|---|
ping google.com | Test basic network connectivity. |
curl ifconfig.me | Show the server’s public IP address. |
ss -tulpn | Show listening ports and associated processes. |
ufw status | Show UFW firewall status and rules. |
ufw allow 443 | Allow incoming traffic on port 443 (HTTPS). |
11. Safe Update & Backup Workflow
Before OS Updates (Ubuntu)
- Take a VPS snapshot in your hosting panel.
- SSH into the server.
- Run
apt update. - Run
apt upgrade -y. - If kernel or core packages updated, run
reboot.
Before n8n / Docker Updates
- Backup n8n data:
cp -r ~/.n8n /root/n8n-backup/
ortar -czvf n8n-backup.tar.gz ~/.n8n - Optionally export workflows and credentials:
docker exec n8n n8n export:workflow --alldocker exec n8n n8n export:credentials --all - Update image:
docker pull n8nio/n8n - Restart stack:
docker compose downdocker compose up -d
Rule of thumb: snapshot before big OS changes; folder/file backups before app/container changes.