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 the711
/drwx--x--x
as I saw mentioned, how is one to do that? Must you create the user and then runchmod
?
useradd
? If you are on Ubuntu and want to use the commandline you should be usingadduser
. (BTW I did not downvote, but not finding the -K option yourself in the help/man page could indicate little research for others as you don't seem to be a complete Unix newbie)-K
part in man - but I did look over it before asking (not well enough). However theman
page still does not explain why it saysIf not specified, the mask will be initialized to 022.
Also, it does not seem thatadduser
provides any other benefit besides an interactive prompt based system - it, too, creates the home directories by default as 755.adduser
in/etc/adduser.conf
.