Skip to content

14. Common Issues & Troubleshooting

14.1 "Permission denied"

bash
# Check file permissions
ls -la /path/to/file

# Check current user
whoami
id

# Solution: modify permissions or use sudo
chmod +x script.sh
sudo chown $(whoami):$(whoami) file.txt
sudo command

14.2 "No space left on device" — Disk Full

bash
# 1. Check disk space
df -h

# 2. Find the directories using the most space
du -sh /* 2>/dev/null | sort -rh | head -10
du -sh /var/* | sort -rh | head -10

# 3. Clean common junk
sudo apt autoremove           # Clean unused packages
sudo apt clean                # Clean download cache
sudo journalctl --vacuum-size=100M  # Clean logs
sudo rm -rf /tmp/*            # Clean temporary files

# 4. Note: it may be inode exhaustion (not space)
df -i                         # Check inode usage
bash
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        50G   48G     0 100% /

$ du -sh /var/* | sort -rh | head -5
15G	/var/log
12G	/var/cache
8G	/var/lib
2G	/var/www
50M	/var/backups

14.3 "Connection refused"

bash
# 1. Check if the service is running
systemctl status nginx

# 2. Check if the port is listening
ss -tulnp | grep :80

# 3. Check firewall
sudo ufw status
sudo iptables -L -n

# 4. Check service configuration
sudo nginx -t              # Nginx config check
sudo apache2ctl configtest  # Apache config check

# 5. View error logs
tail -20 /var/log/nginx/error.log

14.4 Forgotten Root Password

bash
# At the GRUB boot screen:
# 1. Select Advanced options → Recovery mode
# 2. Select root (Drop to root shell)
# 3. Remount root filesystem as read-write
mount -o remount,rw /

# 4. Change password
passwd root

# 5. Reboot
reboot

14.5 Black Screen After Boot / Can't Enter GUI

bash
# Switch to TTY (Ctrl+Alt+F3)

# Reinstall display driver
sudo apt install --reinstall ubuntu-desktop
sudo systemctl restart gdm3

# Check Xorg log
cat /var/log/Xorg.0.log | grep EE

# Reconfigure display manager
sudo dpkg-reconfigure gdm3

14.6 General Troubleshooting Approach

💡 Tip: 💡 The universal 5-step troubleshooting method: View logs: journalctl -xe, tail -f /var/log/syslog. Check status: systemctl status service, ps aux | grep. Verify config: Check config file syntax, ports, paths. Test network: ping, ss -tulnp, curl localhost. Check permissions: ls -la, id, getfacl.