← Back to VPS & Dedicated

Managing Server Users and Permissions

Proper user management on a Linux VPS limits damage if an account is compromised and ensures each user or application only has the access it needs.

Creating a User

# Create user\nadduser deploy\n\n# Add to sudo group (if admin access needed)\nusermod -aG sudo deploy\n\n# Switch to user\nsu - deploy

Linux File Permissions

Linux permissions have three sets: owner, group, others. Each set has read (r=4), write (w=2), execute (x=1):

  • chmod 755 /var/www/html β€” owner full, others read+execute
  • chmod 644 index.php β€” owner read+write, others read only
  • chown www-data:www-data /var/www/html -R β€” change ownership to web server user

Web Server User (www-data)

Apache and Nginx run as the www-data user. Web files should be owned by your deploy user with group www-data. This allows the web server to read files without being able to write to them (preventing certain attacks).

Was this article helpful?

On This Page