0

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?

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

2 Answers 2

4

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.

0

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

% ssh dvpsmf
[email protected]'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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .