Linux Essential Skills Crash Course Part 3: Users, Groups, and Permissions
Mastering users, groups, and permissions is fundamental to secure WordPress hosting on Ubuntu servers. This comprehensive guide breaks down these essential concepts, making them accessible for beginners while providing detailed insights for practical implementation.
{
font-family: 'Fira Code', monospace;
font-size: 14px;
background: #f4f4f4;
display: block;
padding: 10px;
border-radius: 5px;
white-space: pre-wrap; /* Wrap long lines */
word-break: break-word; /* Break words if too long */
}
Understanding Linux Users
Root User (Superuser)
- Complete administrative control
- Unrestricted access to all system components
- Username: “root”
- Can perform any system operation
- Highest level of privileges
System Users
- Created automatically by the system
- Run specific services and processes
- Limited privileges
- Enhanced system security
- Non-interactive accounts
Normal Users
- Regular human accounts
- Limited permissions by default
- Access to personal home directory
- Can run applications
- Customizable privileges
The Sudo System
Working with Root Privileges
- Never work directly as root
- Use sudo to invoke root privileges
- Add users to root group for sudo access
- Always verify commands before using sudo
Best Practices
- Double-check destructive commands
- Use sudo only when necessary
- Keep sudo log files for auditing
- Never share sudo privileges unnecessarily
Linux Groups Explained
Purpose and Function
- Organize users efficiently
- Manage shared permissions
- Control resource access
- Implement security policies
Group Types
- User Groups
- Created automatically
- Named after user
- Primary group for user files
- System Groups
- Created by system
- Used for services
- Example: www-data for web server
- Custom Groups
- Administrator created
- Specific access control
- Project or function based
File System Information
Understanding Directory Listings
drwxr-xr-x 2 root root 4096 Jan 15 10:30 directory
Listing Components
- Type and permissions (drwxr-xr-x)
- Link count (2)
- Owner (root)
- Group (root)
- Size (4096)
- Modification date (Jan 15 10:30)
- Name (directory)
Ownership System
Basic Concepts
- Every file has an owner
- Every file has a group owner
- Other users have separate permissions
- Ownership affects access rights
Managing Ownership
# Change user and group ownership
sudo chown user:group filename
# Change only group ownership
chgrp group filename
Permission System
Permission Types
For Files
- Read (r): View content
- Write (w): Modify/delete
- Execute (x): Run program
For Directories
- Read (r): List contents
- Write (w): Create/delete files
- Execute (x): Access directory
Numeric Permission Values
- Read = 4
- Write = 2
- Execute = 1
Common Permission Combinations
644 (-rw-r--r--) : Standard file
755 (drwxr-xr-x) : Standard directory
600 (-rw-------) : Secure file
WordPress-Specific Configurations
Directory Permissions
wp-admin/ : 755
wp-content/ : 755
wp-includes/ : 755
uploads/ : 775
File Permissions
wp-config.php : 600
.htaccess : 644
PHP files : 644
Image files : 644
Ownership Structure
- Files:
- Owner: Your user account
- Group: Web server (www-data)
- Directories:
- Owner: Your user account
- Group: Web server (www-data)
Security Best Practices
Never Use 777
- Avoid full permissions (777)
- Creates security vulnerabilities
- Bypasses access controls
- Attracts malicious activity
Permission Guidelines
- Use minimum necessary permissions
- Regularly audit permissions
- Document permission changes
- Test after permission changes
- Back up before modifying permissions
Common Issues and Solutions
- Plugin Installation Problems
- Temporary permission adjustment
- Return to secure settings
- Use FTP alternatives
- Update Issues
- Document default permissions
- Create update procedure
- Verify after updates
Command Reference
Essential Permission Commands
# View permissions
ls -l filename
# Change permissions (numeric)
chmod 644 filename
# Change permissions (symbolic)
chmod u+rw,g+r,o+r filename
# Change ownership
chown user:group filename
Next Steps
In the upcoming sections, we’ll cover:
- File and directory manipulation
- Working with text editors
- Process management
- Service control and monitoring
Remember: Understanding permissions is crucial for server security. Take time to practice these concepts before moving forward with server configuration.