I'm a new user of CentOS and now I want to create a new user of my system and let it can only access one directory.

First I create a group named test.

Then:

useradd -g test -d /home/disk/disk1/testDir testuser

The disk1 is a real disk which is mounted in disk1 folder.

And now I can see the testDir folder and its ll output is :

drwx------ 2 testuser test  4096 Jul 27 14:48 testDir

And after I set the password and login with testuser by putty. It says:

Could not chdir to home directory /home/disk/disk1/testDir: Permission denied

The folder exists and owned by testuser. I do not understand why it got permission denied?

  • What ls -ld /home/disk and ls -ld /home/disk/disk1 return? – cuonglm Jul 27 '15 at 7:07
  • @cuonglm Thanks, I find /home/disk is belong to other user. Plz post your answer and I will accept it . – zzy Jul 27 '15 at 7:08
up vote 3 down vote accepted

When you can not access to the directory you have right permissions, the first thing you should check is your access rights with parent directories:

ls -ld /home/disk

and:

ls -ld /home/disk/disk1

You need at least execute permission to access the child of those directories.

Weirdly, on a RHEL6.5 install, the two-up directory permissions prevented login:

% ssh dvpsmf
blah@dvpsmf.test.com.au's password: 
Last login: Wed Feb  3 11:08:03 2016 from 10.14.107.212
Could not chdir to home directory /osp/local/home/blah: Permission denied 
$ 
$ ls -ld --context / /osp /osp/local /osp/local/home
ls: cannot access /osp/local/home: Permission denied
dr-xr-xr-x. root  root system_u:object_r:root_t:s0      /
drwxr-xr-x. root  root system_u:object_r:etc_runtime_t:s0 /osp
drwxr-x---  abcde osp  ?                                /osp/local
$
$ sudo ls -ld --context / /osp /osp/local /osp/local/home
dr-xr-xr-x. root  root system_u:object_r:root_t:s0      /
drwxr-xr-x. root  root system_u:object_r:etc_runtime_t:s0 /osp
drwxr-x---  abcde osp  ?                                /osp/local
drwxr-x---  abcde in   ?                                /osp/local/home
$

User was already member of group in - adding to group osp fixed login

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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