Hostxpeed
Login Get Started →
Troubleshooting

Fix User Cannot Write to Directory

4 min read
33 views
Jun 12, 2026

Understanding the Error

Permission denied: Unable to write to directory

Check Current Permissions

ls -la /path/to/directory
# Shows: drwxr-xr-x (owner:group)

Fix 1: Change Ownership

# Make user the owner
sudo chown username:username /path/to/directory

# Or change group
sudo chown :groupname /path/to/directory
sudo usermod -aG groupname username

Fix 2: Adjust Permissions

# Give write to owner
sudo chmod 755 /path/to/directory  # Owner write only
sudo chmod 775 /path/to/directory  # Group write
sudo chmod 777 /path/to/directory  # Everyone write (not secure)

Fix 3: Apply Recursively

# For all files and subdirectories
sudo chown -R username:username /path/to/directory
sudo chmod -R 755 /path/to/directory

Fix 4: Check Parent Directories

Need execute permission on all parent directories:

# Ensure parents have execute
sudo chmod 755 /home
sudo chmod 755 /home/username

Fix 5: SELinux Context

# Check context
ls -Z /path/to/directory

# Restore default context
sudo restorecon -Rv /path/to/directory

Fix 6: ACL Permissions (Advanced)

# Check ACLs
getfacl /path/to/directory

# Add user write via ACL
setfacl -m u:username:rwx /path/to/directory

Fix 7: Web Server Write Permissions

For web uploads (WordPress, etc.):

sudo chown -R www-data:www-data /var/www/html/uploads
sudo chmod -R 755 /var/www/html/uploads

Was this article helpful?