I have a couple of questions: (Sysadmins tasks)

Here is what I asked to do

Create user Tim and add him to the supplementary group Webdev (Create the group if it doesn't exist), also Set Tim's default home directory to /websites - if this directory does not exist, create it.

So here is what I did:

useradd -m -d /websites Tim 
groupadd Webdev
useradd -aG Webdev Tim

I think I did that correctly.

Now for the second task, I am really confused

Apply the same SELinux contexts and permissions to /websites that would be found on a user's /home directory such that Tim and only Tim will have access to /websites

How would I be able to do that ? I mean should the Tim's home directory be /websites anyways ?


First question: Yes. Although you could have used the -G option to add the supplementary group Webdev at account creation time: -G Webdev.

SELinux marks users' home directories as user_home_dir_t. Therefore to set the SELinux context you can use:

# chcon -t user_home_dir_t /websites

Note that if you had another user's home directory as reference, you could also copy it with # chcon --reference=<other home> /website

To set owner (Tim):

# chown Tim: /website

The colon (:) after the username tells chown to set the group ownership to be the same. That is, ls -ld /website will show Tim Tim.

To set permissions:

# chmod 755 /website

755 is the default for home directories on most (all?) systems and translates to rwxr-xr-x.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.