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.