1

I am trying to learn how the file permission system works. I have a group with group common. Then I created 2 accounts; bob and alice with useradd -m -G common bob/alice. I have created a password for them both. Then I switched user to alice with su alice and created a directory mkdir shared. Then I change the ownership chgrp common shared and permission for this folder chmod 740 shared. Now when I test it I can access the directory with alice. However, when I switch user to bob and try to access the folder it says bash: cd: shared/: Permission denied. What am I doing wrong? The members of the group should all have read permission.

  • please set the permission to 750 to allow group searches. let me know how it goes – George Udosen Dec 9 '16 at 0:54
  • It works. However, I don't know why. Shouldn't read permission be enough? – Mr.H123 Dec 9 '16 at 0:55
  • see my answer below – George Udosen Dec 9 '16 at 1:01
1

It is a quirk of UNIX.

To do ls on a directory, you need to have execute permission on the directory.

If you only have read permission, you can access the files in the directory but you have to know about them first! e.g.

As Alice:

echo "Hello Bob" > shared/hello

As Bob:

cat shared/hello

If you want Bob to be able to ls (or cd to) the common directory:

chmod 750 shared
| improve this answer | |
  • I'll but I can't now as I have to wait for 4 minutes.... :( – Mr.H123 Dec 9 '16 at 0:50
0

Please note the following about permissions in linux:

  • (r) read allows opening a file given its name
  • (w) write allows creating files
  • (x) execute allows listing or searching files.

So you need to make the permission the folder this 750 for the other user to access it, and because it was created by Alice she has r,w,x on but since the permission now is 740 bob won't be able to access it.

| improve this answer | |

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.