2

I am having below directory structure.

/DR/Sub/X1/...
       /X2/...
       /X3/...
       .......

I want to give acces permissions to user but in below manner, when ever i create new directory like X1,X2,X3 suppose i create X4 i want to create new user for this new directory which will only and only access /DR/Sub/X4/... directory.....i.e. new user for new directory how can i achieve this.

Thanks in advance..

  • additionally to the answers below (that i would suggest you) it depends on what you REALLY want to do. If you want the directories because of SSH users you can think about jailing them to a specific dir: googlehemsida.se/c/Ubuntu_-_Jail_user_to_folder - it really depends on your intention. See chroot / jail. – Wolfgang Feb 13 '14 at 10:25
3

The following commands will create user X4 and (by default) group X4 and directory X4, and will limit access to directory X4 to user X4 exclusively.

sudo adduser X4
sudo mkdir X4
sudo chown X4:X4 X4
sudo chmod 0750 X4

Note that nothing will prevent X4 from rummaging around elsewhere on the file system. There is no way to prevent that. However, no one except X4 and root will be able to access directory X4.

  • thanks , and if i want to provide some user name and password to access X4 by user X4 then how can i do that? – Dipak Feb 13 '14 at 10:19
  • Username is X4 (specified by "adduser X4" and password can be set by using the passwd utility: "passwd X4") – Wolfgang Feb 13 '14 at 10:21
  • OK thanks i will try it now and if i done i will let u know. – Dipak Feb 13 '14 at 10:23
0

You can just create user using sudo adduser username --home dir, where dir can be any directory.

For example sudo adduser X4 --home /DR/Sub/X4.

This will create user X4 and specified directory accessible only by X4.

  • hi , i have created 2 users X3 and X4 but when i login using X3 it is accessing X4's directory – Dipak Feb 13 '14 at 10:44

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.