Linux – SETUID Permission Denied

linuxsetuid

I have been learning Linux from few days, and now I was trying to learn the advanced file permissions like setting UID, GID and sticky bit.
At root I have first changed the ownership of directory to Pavan and g1 group, then, done this:

[root@localhost sdcdir]# ll
total 20
drwx------. 2 root  root 16384 Mar 21 21:38 lost+found
drw-r----T. 2 Pavan g1    4096 Mar 22 11:41 testdir
[root@localhost sdcdir]# chmod 4660 testdir/
[root@localhost sdcdir]# ll
total 20
drwx------. 2 root  root 16384 Mar 21 21:38 lost+found
drwSrw----. 2 Pavan g1    4096 Mar 22 11:41 testdir

After logging in as Pavan I am not able to use CD or Ls on that directory, I am getting the following error:

[Pavan@localhost sdcdir]$ ll
total 20
drwx------. 2 root  root 16384 Mar 21 21:38 lost+found
drwSrw----. 2 Pavan g1    4096 Mar 22 11:41 testdir
[Pavan@localhost sdcdir]$ cd testdir/
bash: cd: testdir/: Permission denied
[Pavan@localhost sdcdir]$ 

Could you please guide me where I have gone wrong.
Thank you.

Best Answer

Directory needs execute permission (x) for you to enter it. Try

chmod 4770 testdir/

instead.

If you want to grant someone access to enter a directory but not to be (easily) browse its contents, you can grant just the execute permission and not give read permission at all:

chmod 4110 testdir/
Related Topic