Linux Troubleshooting Checklist: Disk Full, Port in Use, Permission Denied and More

By Furi Sherpa Lama · November 3, 2026 · 20 min read

Most problems on a Linux server are one of the same five: the disk is full, a port is already taken, a service won't start, something gets "Permission denied", or the machine runs out of memory. They're also the five things interviewers ask about most when hiring for DevOps and cloud roles, because how you handle them shows whether you've actually run a server.

This post takes each problem in turn: what the error looks like, the commands that find the cause, the fix, and how to stop it happening again. It starts with a quick check you can run on any broken server, and ends with how to answer troubleshooting questions in an interview.

I broke each of these on purpose in a throwaway Ubuntu 24.04 lab, so every piece of terminal output here is real. To follow along you need a Linux machine where you can use sudo: a cloud VM, a local VM or a spare PC. Don't practise on a server other people depend on.

Start With the Error Message

The fastest way to fix a problem is to read the exact error. Linux error messages are short but precise, and each of the five problems has its own:

Map from five common Linux error messages to the problem behind each and the first command to run: No space left on device means the disk is full, check df -h; Address already in use means another process has the port, check ss -tlnp; status=203/EXEC or status=1/FAILURE means the service failed, check journalctl -u; Permission denied means users, groups or modes, check namei -l; Killed or oom-kill means the out-of-memory killer ran, check dmesg

If you don't have an error message yet, find one. It's almost always in one of three places:

  • the terminal where you ran the command
  • the service's log: sudo journalctl -u <service>
  • the kernel's log: sudo dmesg -T

The First Five Minutes on Any Broken Server

When you log in to a server and only know that "something is wrong", run these before guessing. Each takes a second, and together they cover all five problems:

uptime                                           # how long it's been up, and the load
df -h                                            # disk space on every filesystem
df -i                                            # inodes (file count) on every filesystem
free -h                                          # memory and swap
systemctl --failed                               # services that have failed
sudo journalctl -p err -b --no-pager | tail -20  # errors since the last boot
sudo ss -tlnp                                    # what's listening on which port
sudo dmesg -T | tail -20                         # recent kernel messages, including OOM kills

Also ask: what changed? A deploy, a package upgrade, a config edit, a new cron job. Most outages start right after a change, and journalctl timestamps will often line up with it.

1. Disk Full: "No space left on device"

What it looks like

Writes start failing everywhere: logs stop, databases refuse writes, apt fails, and sometimes you can't even save a file. Here my test app's log directory is full:

furi@server:~$ echo hello > /var/log/app/test.txt
bash: line 1: echo: write error: No space left on device
furi@server:~$ df -h /var/log/app
Filesystem      Size  Used Avail Use% Mounted on
tmpfs            20M   20M     0 100% /var/log/app

Find what's using the space

df -h shows which filesystem is full. Then use du to walk down from its mount point, one level at a time, biggest first:

sudo du -xh --max-depth=1 / 2>/dev/null | sort -rh | head
  • -x stays on one filesystem, so it doesn't count other disks mounted inside it.
  • --max-depth=1 gives one line per folder.
  • sort -rh sorts human-readable sizes, biggest first.

Then go one level deeper into the biggest folder (/var, then /var/log, and so on) until you find it:

furi@server:~$ sudo du -h --max-depth=1 /var/log | sort -rh | head -5
21M	/var/log
20M	/var/log/app
52K	/var/log/apt
furi@server:~$ ls -lh /var/log/app
total 20M
-rw-r--r-- 1 root root 1.0M Nov 20 19:12 access.log
-rw-r--r-- 1 root root  19M Nov 20 19:12 app.log
-rw-r--r-- 1 furi furi    0 Nov 20 19:12 test.txt

One 19 MB log file filled this disk. Notice test.txt exists but is empty: creating the file worked, but writing to it didn't.

If you have it, ncdu (sudo apt install ncdu) does the same thing interactively and is faster to explore.

The usual suspects

What Check Clean up
Application logs ls -lh /var/log/<app> Delete or compress old ones, then set up logrotate
The systemd journal journalctl --disk-usage sudo journalctl --vacuum-size=200M
Old packages du -sh /var/cache/apt sudo apt clean and sudo apt autoremove
Docker images, containers and build cache docker system df docker system prune (removes stopped containers, unused networks and dangling images)
Old backups or dumps sudo find / -xdev -size +500M -exec ls -lh {} \; Move them off the server

Deleted a file, but the space didn't come back?

This one catches everyone once. If a running process still has a file open, deleting it only removes the name. The space isn't freed until the process closes it:

Terminal: after sudo rm of a 19 MB log file, df still shows the disk 100% full. sudo lsof +L1 lists python3 still holding /var/log/app/app.log (deleted). Truncating the file through /proc/2106/fd/3 brings usage down to 5%

lsof +L1 lists open files with no names left (a link count below 1). You have two ways to get the space back:

  • Restart the process that holds it, for example sudo systemctl restart myapp. This is the clean fix.
  • Truncate the file through /proc if you can't restart right now: the PID and FD columns of lsof give the path, here /proc/2106/fd/3. The w in 3w means it's open for writing.

To avoid this, don't delete a log file that's still being written. Empty it instead with sudo truncate -s 0 file.log, or let logrotate handle it.

Disk full, but df -h shows free space?

Then you've run out of inodes. Every file uses one inode, whatever its size, and a filesystem has a fixed number of them. Millions of tiny files (sessions, cache entries, mail queues) can use them all up while the disk is nearly empty:

furi@server:~$ for i in $(seq 1 500); do echo x > /srv/cache/session-$i; done
bash: line 1: /srv/cache/session-200: No space left on device
bash: line 1: /srv/cache/session-201: No space left on device
[... 299 more lines like these ...]
furi@server:~$ df -h /srv/cache
Filesystem      Size  Used Avail Use% Mounted on
tmpfs            50M  796K   50M   2% /srv/cache
furi@server:~$ df -i /srv/cache
Filesystem     Inodes IUsed IFree IUse% Mounted on
tmpfs             200   200     0  100% /srv/cache

2% of the space used, but 100% of the inodes. To find which folder holds the most files:

sudo find / -xdev -type f | cut -d/ -f2-3 | sort | uniq -c | sort -rn | head

Then delete the old files, and fix whatever creates them without cleaning up.

Prevent it

  • Set up logrotate for every application that writes its own logs.
  • Cap the journal in /etc/systemd/journald.conf with SystemMaxUse=500M.
  • Alert before the disk is full, at 80% for example, with whatever monitoring you use (CloudWatch, Prometheus, Grafana).

In an interview: "I check df -h to see which filesystem is full, and df -i in case it's inodes. Then I use du to find the biggest folders. If deleting files doesn't free space, I check lsof +L1 for deleted files that are still open. Then I fix the cause, usually log rotation."

2. Port Already in Use: "Address already in use"

What it looks like

Your app won't start because something else is already listening on its port:

Terminal: python3 -m http.server 8080 fails with OSError: [Errno 98] Address already in use. sudo ss -tlnp shows python3 with PID 2295 listening on port 8080, sudo lsof -nP -i :8080 shows it belongs to the deploy user, ps shows it is python3 -m http.server 8080 running for 15 seconds, and after sudo kill 2295 the port is free

Every language words it slightly differently (EADDRINUSE in Node.js, bind() to 0.0.0.0:80 failed (98: Address already in use) in Nginx), but it's the same error.

Find who has the port

sudo ss -tlnp 'sport = :8080'
  • -t TCP, -l listening sockets only, -n numbers instead of names, -p the process.
  • Without sudo, ss can't show processes owned by other users, so the last column comes back empty.

lsof -nP -i :8080 gives the same answer with the user, and ps -o pid,user,etime,cmd -p <PID> shows exactly what the process is and how long it's been running.

The usual causes

  • An old copy of your app is still running. You started it by hand in a terminal or with nohup, then started the systemd service too. Stop the stray one and use only the service.
  • Another service uses the same port. Apache and Nginx both want port 80, and many dev servers default to 3000, 5000 or 8080.
  • A Docker container publishes the port. ss shows the process as docker-proxy. Find the container with docker ps and look at the PORTS column.

Fix it

Stop the process the right way, depending on what it is:

sudo systemctl stop apache2        # a service: stop it (and disable it if it shouldn't run at all)
docker stop <container>            # a container
kill <PID>                         # anything else; kill -9 only if it ignores this

Plain kill sends SIGTERM, which lets the process shut down cleanly. kill -9 (SIGKILL) can't be caught, so the process can't save anything or close connections. Use it only as a last resort. The other fix is to change your app's port.

The opposite problem: "Connection refused"

If clients get Connection refused, nothing is listening on that port at all. Check ss -tlnp again:

  • Nothing there: the app isn't running. Go to the next section.
  • Listening on 127.0.0.1:8080: it only accepts connections from the server itself. Make it listen on 0.0.0.0, or put Nginx in front of it.
  • Listening on 0.0.0.0:8080, but clients outside still time out: a firewall is in the way. Check ufw status on the server and the cloud's security group.

In an interview: "I'd run ss -tlnp to see which process holds the port, then ps to find out what it is. Usually it's an old instance or another service. I'd stop it properly with systemctl stop or docker stop, and only use kill -9 if nothing else works."

3. A Service That Won't Start

Read the status first

sudo systemctl status myapp

The two lines that matter are Active: and the Process: line with the exit status. Here my app's service file points ExecStart at Node.js, which isn't installed:

furi@server:~$ sudo systemctl status myapp --no-pager
× myapp.service - My web app
     Loaded: loaded (/etc/systemd/system/myapp.service; disabled; preset: enabled)
     Active: failed (Result: exit-code) since Fri 2026-11-20 19:13:47 UTC; 5s ago
   Duration: 3ms
    Process: 150 ExecStart=/usr/bin/node /opt/myapp/server.js (code=exited, status=203/EXEC)
   Main PID: 150 (code=exited, status=203/EXEC)
        CPU: 1ms

What the exit status tells you

Numbers from 200 up come from systemd itself: it failed while setting up the process, before your app ran at all.

Status Means Check
203/EXEC systemd couldn't run the ExecStart program The path exists (which node), is executable, and a script starts with a #! line
200/CHDIR The WorkingDirectory doesn't exist ls -ld the folder
217/USER The User= doesn't exist id <user>
1/FAILURE or another low number Your app started, then exited with an error The app's own output, in the journal
9/KILL with Result: oom-kill The kernel killed it for using too much memory Section 5

Read the logs

For anything below 200, the reason is in your app's own output, which systemd saves in the journal. I fixed the path, and the app now crashes on startup instead:

Terminal: sudo journalctl -u myapp shows the service starting, then a Python traceback ending in FileNotFoundError: No such file or directory: /opt/myapp/config.json, then status=1/FAILURE, five restarts and Start request repeated too quickly

The traceback says exactly what's wrong: the config file is missing. Useful journalctl options:

sudo journalctl -u myapp -n 50 --no-pager   # the last 50 lines
sudo journalctl -u myapp -f                 # follow live, like tail -f
sudo journalctl -u myapp -b                 # since the last boot
sudo journalctl -u myapp --since "10 min ago"

"Start request repeated too quickly"

With Restart=on-failure, systemd restarts a crashing service, but by default it gives up after 5 starts within 10 seconds. After you fix the cause, clear the failed state and start it again:

furi@server:~$ echo '{"port": 8080}' | sudo tee /opt/myapp/config.json
{"port": 8080}
furi@server:~$ sudo systemctl reset-failed myapp
furi@server:~$ sudo systemctl start myapp
furi@server:~$ systemctl is-active myapp
active
furi@server:~$ sudo journalctl -u myapp --no-pager -n 2
Nov 20 19:14:31 server systemd[1]: Started myapp.service - My web app.
Nov 20 19:14:31 server python3[319]: Listening on port 8080

It works when I run it by hand, but not as a service

A service doesn't run the way your terminal does:

  • Different user. User=deploy runs it as deploy, which may not be able to read your files. Test exactly as the service would: sudo -u deploy /usr/bin/python3 /opt/myapp/server.py.
  • No shell setup. Your .bashrc, aliases and PATH additions aren't loaded, so tools installed with nvm or pyenv aren't found. Use full paths in ExecStart.
  • No environment variables from your session. Set them with Environment=KEY=value, or EnvironmentFile=/etc/myapp.env for a file of them.
  • A different working directory. Relative paths in your app resolve from WorkingDirectory, or from / if it isn't set.

Common mistakes after editing a service

  • Forgetting sudo systemctl daemon-reload after changing a .service file. systemd keeps using the old version until you reload.
  • Starting it but not enabling it. start runs it now, enable makes it start at boot. sudo systemctl enable --now myapp does both. The status line shows which: disabled means it won't come back after a reboot.
  • A typo in the unit file. systemd-analyze verify /etc/systemd/system/myapp.service checks it.

To see every failed service at once:

furi@server:~$ sudo systemctl list-units --type=service --state=failed --no-pager
  UNIT          LOAD   ACTIVE SUB    DESCRIPTION
● myapp.service loaded failed failed My web app

In an interview: "systemctl status first, for the state and the exit code. A code of 200 or above means systemd couldn't start the process, usually a wrong path, user or folder. Otherwise the app crashed, so I read journalctl -u for its error. Then I fix it, run daemon-reload if I changed the unit file, and reset-failed if it hit the restart limit."

4. Permission Denied

Read the permissions

"Permission denied" means the user running the command isn't allowed to do it. First find out who you are, and who the file belongs to:

deploy@server:~$ echo "<h1>Hello</h1>" > /var/www/app/index.html
bash: line 1: /var/www/app/index.html: Permission denied
deploy@server:~$ ls -ld /var/www/app
drwxr-xr-x 2 root root 4096 Nov 20 19:12 /var/www/app
deploy@server:~$ id
uid=1002(deploy) gid=1002(deploy) groups=1002(deploy)

drwxr-xr-x root root reads as: a directory, where the owner (root) can read, write and enter it, and the group (root) and everyone else can only read and enter it. deploy is neither the owner nor in the group, so it can't create files there.

The fix is to give the right user ownership, not to open it to everyone:

sudo chown -R deploy:deploy /var/www/app

Never fix permissions with chmod 777. It lets every user and every process on the server change those files, including a compromised web app.

Check the whole path with namei

To read a file you need permission on the file and execute (x) permission on every directory above it. ls -l on the file alone doesn't show that. namei -l shows every step and where it's blocked:

deploy@server:~$ cat /srv/config/app.env
cat: /srv/config/app.env: Permission denied
deploy@server:~$ namei -l /srv/config/app.env
f: /srv/config/app.env
drwxr-xr-x root root /
drwxr-xr-x root root srv
drwx------ root root config
                      app.env - Permission denied

The file itself might be readable, but config is drwx------: only root can enter it.

Scripts that won't run

deploy@server:~$ ./deploy.sh
bash: line 1: ./deploy.sh: Permission denied
deploy@server:~$ ls -l deploy.sh
-rw-r--r-- 1 deploy deploy 32 Nov 20 19:12 deploy.sh
deploy@server:~$ chmod +x deploy.sh
deploy@server:~$ ./deploy.sh
Deploying...

No x in -rw-r--r--, so it can't be run directly. chmod +x fixes it, and bash deploy.sh works even without it. Files copied from Windows or downloaded often lose the execute bit.

sudo and redirection

This catches a lot of people:

sudo echo "127.0.0.1 myapp.local" >> /etc/hosts     # Permission denied
echo "127.0.0.1 myapp.local" | sudo tee -a /etc/hosts   # works

In the first line sudo only applies to echo. The >> redirection is done by your own shell, as your own user, before sudo runs. tee writes the file itself, so running tee with sudo works.

Other causes

  • You were just added to a group. After sudo usermod -aG docker deploy, the user has to log out and back in before the new group counts. Check with id.
  • Ports below 1024. Only root can listen on ports like 80 and 443, so an app running as a normal user gets Permission denied (EACCES) when it tries. Put Nginx in front of it, or give the program the right with sudo setcap 'cap_net_bind_service=+ep' /path/to/binary.
  • The filesystem is mounted noexec. Some servers mount /tmp this way, so nothing in it can run, whatever its permissions. Check with mount | grep noexec.
  • AppArmor or SELinux. If the permissions look right and it's still denied, a security module may be blocking it. On Ubuntu, look for apparmor="DENIED" in sudo dmesg. On Red Hat-based systems, check sudo ausearch -m avc.
  • SSH says Permission denied (publickey). That's an SSH key problem, not a file one. My SSH for Beginners post covers fixing it.

In an interview: "I check who I'm running as with id, then the permissions with ls -l, and namei -l for the whole path, since every directory needs x. I fix it with the right owner or group, never chmod 777. If permissions look right, I check for noexec mounts and AppArmor or SELinux."

5. Out of Memory: "Killed"

What it looks like

When the machine (or a service's memory limit) runs out of memory, the kernel's OOM killer picks a process and kills it with SIGKILL. The process gets no warning and can't save anything. Depending on where you look:

  • In a terminal, the command just prints Killed.
  • A Docker container exits with code 137 (128 + 9, the SIGKILL number), and docker inspect shows "OOMKilled": true.
  • A systemd service fails with Result: oom-kill.

Here a worker service with a memory leak runs into its 100 MB limit:

Terminal: sudo systemctl status worker shows Active: failed (Result: oom-kill), the process killed with signal KILL, and the journal: the worker's cache grows from 30 MB to 90 MB, then A process of this unit has been killed by the OOM killer

Confirm it was the OOM killer

The kernel logs every OOM kill:

furi@server:~$ sudo dmesg -T | grep -i 'killed process'
[Fri Nov 20 19:14:49 2026] Memory cgroup out of memory: Killed process 77842 (python3) total-vm:117556kB, anon-rss:102108kB, file-rss:6420kB, shmem-rss:0kB, UID:1002 pgtables:264kB oom_score_adj:0
  • Memory cgroup out of memory means it hit its own limit (MemoryMax= in systemd, --memory in Docker, or a Kubernetes memory limit). If the whole server ran out, the line starts with Out of memory instead.
  • anon-rss:102108kB is how much memory it was actually using: about 100 MB, its limit.
  • My lab ran inside a container, so the kernel's PID (77842) differs from the one systemd showed. On a normal server they match.

sudo journalctl -k | grep -i 'killed process' finds the same lines, and also searches before the last boot if your journal is persistent.

Check memory now

furi@server:~$ free -h
               total        used        free      shared  buff/cache   available
Mem:            14Gi        10Gi       225Mi       621Mi       5.1Gi       4.4Gi
Swap:           15Gi         9Mi        15Gi

Don't panic about the small free number. Linux uses spare memory as a disk cache (buff/cache) and gives it back when programs need it. available is the number that matters: how much programs can still get. If it's close to zero, the server is about to run out.

To see which processes use the most memory:

ps aux --sort=-%mem | head          # biggest first; RSS is the real memory used, in KB
top                                  # then press Shift+M to sort by memory
docker stats                         # memory per container

Run ps a few times, a minute apart. A process that only ever grows has a memory leak, like my worker, which kept every batch it processed.

Fix it

  • Fix the leak if the app keeps growing. Restarting it only buys time.

  • Give it a limit, so one process can't take the whole server down with it. That's MemoryMax= in the systemd service, or --memory in Docker. When it's hit, only that service is killed, and Restart=on-failure brings it back.

  • Add swap on small cloud servers. Many 1 GB and 2 GB VMs come with no swap at all, so any spike kills something. A small swap file gives you room:

    sudo fallocate -l 2G /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
    

    Swap is much slower than memory, so it's a safety net, not a fix. If vmstat 1 shows the si and so columns busy all the time, the server needs more memory.

  • Get a bigger server if the app genuinely needs more memory than you have.

In an interview: "I'd confirm it was the OOM killer in dmesg or journalctl -k, and check whether it hit a container or service limit or the whole server ran out. Then free -h, looking at available, and ps --sort=-%mem to find what's using it. The fix depends on whether it's a leak, a missing limit, or a server that's simply too small."

Answering Troubleshooting Questions in an Interview

Questions like "a website is down, what do you do?" have no single right answer. Interviewers want to hear a calm, ordered method. Talk through these steps out loud:

  1. Clarify the problem. Down for everyone or one user? Since when? Did anything change, like a deploy?
  2. Check from the outside in. Does DNS resolve (dig example.com)? Is the server up? Is the port open? Does curl -I get an answer? Each check narrows down where it breaks.
  3. Look at the evidence before changing anything. systemctl status, journalctl, df -h, free -h, ss -tlnp.
  4. Make one change at a time and check the result, so you know what fixed it.
  5. Prevent it next time: an alert, log rotation, a memory limit, a test in the pipeline. Mentioning this step is what makes an answer stand out.

If you don't know a command, say what you'd want to find out and how you'd look it up. Interviewers care more about the reasoning than the exact flags.

Linux Troubleshooting Cheat Sheet

Task Command
Disk space per filesystem df -h
Inodes per filesystem df -i
Biggest folders sudo du -xh --max-depth=1 / | sort -rh | head
Deleted files still open sudo lsof +L1
Journal size, and shrink it journalctl --disk-usage, sudo journalctl --vacuum-size=200M
Docker disk usage, and clean up docker system df, docker system prune
What's listening on a port sudo ss -tlnp 'sport = :8080'
Which process has a port sudo lsof -nP -i :8080
Details of a process ps -o pid,user,etime,cmd -p <PID>
Service state and exit code sudo systemctl status myapp
Service logs sudo journalctl -u myapp -n 50 --no-pager
Follow logs live sudo journalctl -u myapp -f
All failed services systemctl --failed
Reload after editing a unit sudo systemctl daemon-reload
Clear "repeated too quickly" sudo systemctl reset-failed myapp
Start now and at boot sudo systemctl enable --now myapp
Check a unit file systemd-analyze verify /etc/systemd/system/myapp.service
Who am I, and my groups id
Permissions on the whole path namei -l /path/to/file
Give a user ownership sudo chown -R deploy:deploy /var/www/app
Write a root-owned file echo text | sudo tee -a /etc/file
Memory available free -h
Biggest memory users ps aux --sort=-%mem | head
OOM kills sudo dmesg -T | grep -i 'killed process'
Errors since boot sudo journalctl -p err -b

Wrapping Up

The main points:

  1. Read the exact error message first. It usually names the problem.
  2. Collect evidence before changing anything: df, free, ss, systemctl status and journalctl answer most questions in seconds.
  3. Fix the cause, not the symptom: log rotation instead of deleting logs, the right owner instead of chmod 777, a fixed leak instead of a restart.
  4. Make it not happen again, with alerts and limits.

The best way to get good at this is to break things on purpose. Spin up a test VM, fill its disk, start two servers on one port, delete a config file a service needs, and give a process too little memory. Then fix each one using only the commands in this post. When the same thing happens on a real server, you'll already know what to type.

For more on the tools behind these fixes, read SSH for Beginners and HTTPS, TLS and Certificates Explained.