Linux Server Troubleshooting: Common Issues and How to Fix Them
Learn how to troubleshoot common Linux server problems, from permission errors to network issues, with practical, real-world examples.
Introduction
Linux servers are widely used for web hosting, databases, and enterprise applications due to their stability, security, and cost-effectiveness.
However, even experienced sysadmins encounter server issues—from permission errors to network connectivity problems.
In this guide, we’ll explore:
- ⚙️ Key Linux file permissions:
chmod,chown, and Access Control Lists (ACLs) - Common server issues and step-by-step solutions
- ️ Troubleshooting best practices
Understanding Linux Permissions: chmod, chown, and ACLs
Why Permissions Matter
Linux permissions protect files, directories, and system resources from unauthorized access, modifications, or deletions.
1. chmod (Change Mode)
The chmod command modifies file permissions based on three user classes:
- Owner (u)
- Group (g)
- Others (o)
Permission Types:
- Read (r) = 4
- ✏️ Write (w) = 2
- ️ Execute (x) = 1
️ Basic chmod Syntax:
chmod [permissions] [file/directory]
⚙️ Example 1: Assign Permissions Using Octal Notation
chmod 755 script.sh
Explanation:
- 7 (rwx): Owner – read, write, execute.
- 5 (r-x): Group – read, execute.
- 5 (r-x): Others – read, execute.
⚙️ Example 2: Assign Permissions Using Symbolic Notation
chmod u+x script.sh
Explanation: Adds execute permission to the file owner.
2. chown (Change Owner)
The chown command changes the ownership of files and directories.
️ Basic chown Syntax:
chown [owner][:group] [file/directory]
⚙️ Example 1: Change File Ownership
chown john:developers report.txt
Explanation: Changes file ownership to user john and group developers.
⚙️ Example 2: Recursively Change Directory Ownership
chown -R nginx:www-data /var/www/html
Explanation: Applies changes to all files and subdirectories.
3. Access Control Lists (ACLs)
ACLs provide granular permissions beyond the standard owner/group/others model.
️ Common ACL Commands:
# Set ACL for user john
setfacl -m u:john:rwx file.txt
# View ACL
getfacl file.txt
# Remove ACL for user john
setfacl -x u:john file.txt
Example: Grants john read, write, and execute permissions.
️ Linux Server Troubleshooting: Common Issues and Fixes
1. Permission Denied Errors
Error Message:
bash: ./backup.sh: Permission denied
Cause:
- ❌ Missing execute permissions.
- Incorrect file ownership.
- Restricted ACL settings.
️ Fix:
- Check file permissions:
- Add execute permission:
- Run the script again:
ls -l backup.sh
chmod +x backup.sh
./backup.sh
Tip: Use chmod 700 for scripts containing sensitive information.
2. Network Connectivity Issues
Error Message:
ping google.com
ping: unknown host google.com
Cause:
- DNS misconfiguration.
- Firewall blocking traffic.
- ️ Network interface issues.
️ Fix:
- Check DNS resolution:
- Restart networking service:
- Test connectivity:
cat /etc/resolv.conf
sudo systemctl restart networking
ping google.com
Tip: Use traceroute to identify network latency issues.
3. Disk Space Issues
Error Message:
No space left on device
Cause:
- Large log files consuming space.
- ️ Unused temp files accumulating.
- Orphaned Docker volumes.
️ Fix:
- Check disk usage:
- Identify large directories:
- Clear old logs:
- Clean Docker resources:
df -h
du -h /var/log | sort -rh | head -10
sudo journalctl --vacuum-size=500M
docker system prune -af
Tip: Set log rotation to avoid excessive log growth.
Troubleshooting Best Practices
- ✅ Document Everything: Track all configuration changes and fixes.
- Monitor System Health: Use tools like Nagios and Zabbix.
- Follow Least Privilege Principle: Limit access permissions.
- ⚙️ Regularly Update Software: Apply patches promptly.
- Automate Backups: Schedule regular backups and test them periodically.
Conclusion: Mastering Linux Troubleshooting
Linux server troubleshooting requires a combination of
By understanding chmod, chown, and ACLs, you’ll be better equipped to handle common issues effectively.
Key Takeaways:
- Master file permissions:
chmod,chown, and ACLs are essential for server security. - ️ Adopt proactive monitoring: Detect issues early with tools like Prometheus and Nagios.
- Document changes: Maintain logs of all server modifications and fixes.