VPS SSH Commands Cheat Sheet (Linux + Docker + n8n)

VPS SSH Commands Cheat Sheet

Linux VPS (Ubuntu Server) + Docker + n8n + Backups + OS Updates

2. System Monitoring

CommandDescription
topLive process monitor (CPU, RAM, processes).
htopImproved process monitor (if installed).
free -hShow RAM usage in human-readable format.
df -hShow disk usage for all mounted filesystems.
du -sh /pathShow total size of folder /path.
uptimeShow system uptime and load averages.
whoShow logged-in users.

3. Service Management (systemd)

CommandDescription
systemctl status serviceShow status of a service (e.g. nginx, docker).
systemctl restart serviceRestart a service.
systemctl stop serviceStop a service.
systemctl start serviceStart a service.
journalctl -u service -fFollow live logs for a service.

4. Docker Core Commands

CommandDescription
docker psList running containers.
docker ps -aList all containers (including stopped).
docker logs container -fFollow logs of a container (replace container with name/ID).
docker restart containerRestart a container.
docker stop containerStop a container.
docker rm containerRemove a stopped container.
docker imagesList Docker images.
docker rmi imageRemove an image.

5. Docker & n8n Update Commands

Assuming you run n8n via Docker Compose.

CommandDescription
docker pull n8nio/n8nDownload the latest n8n image.
docker compose downStop the n8n stack (from the folder with docker-compose.yml).
docker compose up -dStart the n8n stack in the background with the new image.
docker pull imageUpdate any Docker image (replace image with name).
docker system prune -aRemove unused containers, networks, and images (careful).

Safe pattern: backup n8n data → pull new image → docker compose downdocker compose up -d.

6. OS Update Commands (Ubuntu Server)

CommandDescription
apt updateRefresh package list from repositories.
apt upgrade -yInstall available package updates.
apt dist-upgrade -yPerform a more complete upgrade (may change dependencies).
apt autoremove -yRemove unused packages and dependencies.
rebootReboot the VPS (often needed after kernel updates).
uname -rShow current kernel version.

Best practice: take a VPS snapshot in your provider panel before running major OS upgrades.

7. Backup Commands (Files & Folders)

CommandDescription
cp -r /source /backup/Copy folder /source recursively to /backup/.
tar -czvf backup.tar.gz /folderCreate a compressed backup archive of /folder.
tar -xzvf backup.tar.gzExtract a compressed backup archive.
rsync -av /source /destinationSync /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.

CommandDescription
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.

CommandDescription
pg_dump dbname > backup.sqlBackup a PostgreSQL database named dbname to backup.sql.
mysqldump -u root -p dbname > backup.sqlBackup a MySQL database named dbname (will prompt for password).
gzip backup.sqlCompress the SQL backup file.

10. Network & Connectivity

CommandDescription
ping google.comTest basic network connectivity.
curl ifconfig.meShow the server’s public IP address.
ss -tulpnShow listening ports and associated processes.
ufw statusShow UFW firewall status and rules.
ufw allow 443Allow incoming traffic on port 443 (HTTPS).

11. Safe Update & Backup Workflow

Before OS Updates (Ubuntu)

  1. Take a VPS snapshot in your hosting panel.
  2. SSH into the server.
  3. Run apt update.
  4. Run apt upgrade -y.
  5. If kernel or core packages updated, run reboot.

Before n8n / Docker Updates

  1. Backup n8n data:
    cp -r ~/.n8n /root/n8n-backup/
    or
    tar -czvf n8n-backup.tar.gz ~/.n8n
  2. Optionally export workflows and credentials:
    docker exec n8n n8n export:workflow --all
    docker exec n8n n8n export:credentials --all
  3. Update image:
    docker pull n8nio/n8n
  4. Restart stack:
    docker compose down
    docker compose up -d

Rule of thumb: snapshot before big OS changes; folder/file backups before app/container changes.