Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What are the command(s) to create a new user (not from su), give him the ability to write to only one folder which is some directory owned by an already existing user (the one that created him)? Meaning that the folder is already under some existing user's FS. How can I create another user and only let him write to that folder?

I was told here:

Use useradd, adduser, or whatever utility your unix variant has to create a user. The easiest way to control access to the directory is to make it and its files (but nothing else) owned by a newly created group, and make the new user a member of that group (and no other group).

but I do not know which commands to use to do such thing. So how to do it?

share|improve this question
    
These commands are somewhat distribution specific. What is your distribution? –  Faheem Mitha Jun 16 '11 at 16:08
    
CentOS and OpenSuse –  Kabumbus Jun 16 '11 at 16:09
    
It would be helpful to know a little more about your use case. Specifically, do you not want the user to have a home directory, or do you perhaps want him to have a home directory that is owned by someone else? I'm not sure if that is possible. –  Faheem Mitha Jun 16 '11 at 17:30
    
I do not want the user to have a home directory. –  Kabumbus Jun 16 '11 at 21:35

2 Answers 2

So you want to

  1. create a group;
  2. create a user in that group, without giving that user a home directory to write in;
  3. make a certain directory owned by that group and writable by it.

The following commands should do the trick on any Linux distribution.

groupadd --system myappgroup
useradd -c 'system user for myapp' -d /none -g myappgroup \
        -M -N -r -s /bin/false myappuser
chgrp myappgroup /path/to/directory
chmod g+rwxs /path/to/directory
share|improve this answer

Simple answer, you can't. The system doesn't know who created a user and by default only root has that privilege. A regular user can not create a user without su or sudo. At least that's how I understand it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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