Hey Dev.to 👋
If you came from Medium, welcome back. Part 1 of this series (Nginx commands for managing a Linux server) got a good response over there, so I decided to keep the series going but bring Part 2 here to Dev.to for a change of scenery.
If you haven't read Part 1 yet, it covers the core Nginx workflow: checking if Nginx is running, testing configs before reloading, enabling and disabling sites, reading logs, and testing URLs. You can find it here:
Part 1 on Medium: Nginx Commands I Actually Use: A Running Guide for Managing a Linux Server
This part is different. It's not about Nginx specifically. It's about a problem that shows up after you've been deploying things for a while.
You've got a frontend here, a backend there, some Nginx config you wrote three weeks ago, maybe a Docker container you spun up to test something and then... left running. And then one day something breaks and you're sitting there thinking: okay, what even is on this server right now?
That's what this part is about.
Quick note on setup: I work from a Windows laptop, connecting over SSH via PowerShell. All the commands below run on the server after you SSH in.
ssh {deploy-user}@{your-server-ip}
Anything in {curly braces} is a placeholder. Swap in your own values before running.
Table of Contents
- List All Files (Structure Only)
- Tree View with Sizes
- Full Deployment Snapshot in One Command
- Find What's Eating Your Disk Space
- Quick Reference
1. List All Files (Structure Only)
The bluntest possible tool. Shows every file under the directories you care about, sorted, no frills.
find /var/www/ /home/{deploy-user}/ -type f 2>/dev/null | sort
Output:
/home/deploy/api/build.gradle.kts
/home/deploy/api/src/main/Application.kt
/var/www/{site-1}/index.html
/var/www/{site-1}/robots.txt
/var/www/{site-2}/index.html
Good for a quick "what's actually in here" check. Pipe it through grep if you're looking for something specific, like a file you vaguely remember deploying but can't place.
find /var/www/ /home/{deploy-user}/ -type f 2>/dev/null | sort | grep "robots"
Output:
/var/www/{site-1}/robots.txt
2. Tree View with Sizes
Same idea but actually readable. Shows the folder structure visually with file sizes alongside.
# Only needed once if tree isn't installed
sudo apt install -y tree
tree -h /var/www/ /home/{deploy-user}/ -I 'node_modules|.git'
Output:
/var/www/
├── [4.0K] {site-1}
│ ├── [ 612] index.html
│ └── [ 128] robots.txt
└── [4.0K] {site-2}
└── [ 890] index.html
/home/deploy/
└── [4.0K] api
├── [1.2K] build.gradle.kts
└── [4.0K] src
The -I 'node_modules|.git' flag skips folders that have thousands of files and none of them are yours. Add more patterns as needed:
tree -h /var/www/ /home/{deploy-user}/ -I 'node_modules|.git|build|.gradle'
I reach for this one more than the flat list. The tree shape makes it much easier to see what belongs where at a glance.
3. Full Deployment Snapshot in One Command
This is the one I actually use when I need to remember what I've built.
I kept running ls on different directories separately, then forgetting what I'd already checked. So I started keeping one long command that dumps everything relevant in one go: frontend folders, backend apps, Nginx configs, Docker containers, top to bottom.
echo "=== FRONTEND: {site-1} ===" && \
find /var/www/{site-1} -maxdepth 1 -type f | sort && \
echo "" && \
echo "=== FRONTEND: {site-2} ===" && \
find /var/www/{site-2} -maxdepth 1 -type f | sort && \
echo "" && \
echo "=== BACKEND APPS ===" && \
find /home/{deploy-user} -maxdepth 2 -type f 2>/dev/null | grep -v ".git" | sort && \
echo "" && \
echo "=== NGINX CONFIGS ===" && \
ls -la /etc/nginx/sites-available/ && \
echo "" && \
echo "=== DOCKER CONTAINERS ===" && \
docker ps -a --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"
Output (what it actually looks like):
=== FRONTEND: {site-1} ===
/var/www/{site-1}/index.html
/var/www/{site-1}/robots.txt
=== FRONTEND: {site-2} ===
/var/www/{site-2}/index.html
=== BACKEND APPS ===
/home/deploy/api/build.gradle.kts
/home/deploy/api/Dockerfile
=== NGINX CONFIGS ===
-rw-r--r-- 1 root root 1.1K Jul 20 {site-1}
-rw-r--r-- 1 root root 980 Jul 31 {site-2}
=== DOCKER CONTAINERS ===
NAMES IMAGE STATUS PORTS
{app-name} {image-name} Up 3 days 0.0.0.0:{port}->{port}/tcp
The command looks long but it's not complicated. It's literally just the same few commands chained together with && and echo separators. Adapt the folder paths and site names to match your setup, then save it somewhere because you will want it again.
4. Find What's Eating Your Disk Space
I added this one after noticing the server getting slower and realizing I had months of old build artifacts sitting in /home/deploy/api/build that nobody had cleaned up. This command would have caught it immediately.
du -ah /var/www/ /home/{deploy-user}/ 2>/dev/null | sort -rh | head -50
Output:
1.2G /home/deploy/api/build
340M /home/deploy/api/build/libs/app.jar
88M /var/www/{site-1}/assets
12M /var/www/{site-2}
4.0K /var/www/{site-2}/index.html
Biggest to smallest, top 50 results. If your disk is filling up and you don't know why, this usually tells you in about three seconds.
Drop head -50 if you want the full unfiltered list.
Quick Reference
-
Flat file list:
find /var/www/ /home/{deploy-user}/ -type f 2>/dev/null | sort -
Tree with sizes:
tree -h /var/www/ /home/{deploy-user}/ -I 'node_modules|.git' - Full snapshot: the long one in section 3 (copy, adapt, save it)
-
Disk usage:
du -ah /var/www/ /home/{deploy-user}/ 2>/dev/null | sort -rh | head -50
That's Part 2. Short and focused on one problem: knowing what's actually on your server.
Stay tuned for Part 3.
If Part 1 on Medium was useful too, drop it a like there. Helps more people find it.

Top comments (0)