Linux Permissions – Recommended Permissions for User’s Home Directory and Files

homelinuxpermissionsSecurityusers

I'm working with a fresh install of Ubuntu 12.04 and I've just added a new user:

useradd -m testuser

I thought that the -m flag to create a home directory for users was pretty standard, but now that I've taken a closer look I'm a little confused:

By default the new directory that was just created shows up as:

drwxr-xr-x  4 testuser testuser 4.0K May 20 20:24 testuser

With the g+r and o+r permissions that means every other user on the system can not only cd to that user's home directory, but also see what is stored there.

When reading over some documentation for suPHP it recommends setting the permissions as 711 or drwx--x--x which is how it would make the most sense to me.

I noticed that I can change the permissions on the files inside /etc/skel and they are set correctly when creating new users with useradd -m but changing the permissions on the /etc/skel directory itself does not seem to have any effect on the new directories that are created for users in /home/

  • So – what type of permissions should a user's home directory and files have – and why?

  • If I wanted permissions to be different for useradd -m – like the 711 / drwx--x--x as I saw mentioned, how is one to do that? Must you create the user and then run chmod ?

Best Answer

To make the creation of the home directory behave differently do

useradd -m -K UMASK=0066 testuser

Giving other no access at all should be safe.

Related Question