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+executechmod 644 index.phpβ owner read+write, others read onlychown 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).