Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about "ls -l" resultd

 
Raj Ohadi
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if I have /home/mydir/sample/ direcory and inside this dir I have some files.

First I do "cd /home/mydir/" then do "ls -l", I see

drwxrw-r-- 2 abcde XYZ 1000 Jun 3 09:09 sample
....

which means for "sample" directory, the owner is "abcde" and group is "XYZ".

then I do "cd sample" followed by another "ls -l" I see

-rw-r--r-- 1 abcde OPQ 600 Sep 30 08:08 data1
-rw-r--r-- 1 abcde OPQ 700 Sep 30 09:08 data2
...

which means for these files (data1, data2) under the "sample" folder, the owner is still "abcde" but the group is "OPQ".

How does this make sense ? So, for a user belonging to group "XYZ", he can't read the files under "sample" folder ? But "XYZ" has the "read" priviledge to the "sample" folder so theie members are supposed to read things under this folder, correct ?

Similarly, for a user in "OPQ" group, they should be able to read "data1" file, but why can he do that while he doesn't belong to "XYZ" group at all (which menas he is blocked from the "sample" directory) ?

Why do we often seen such setting in UNIX ?
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

So, for a user belonging to group "XYZ", he can't read the files under "sample" folder ?


No. The file and directory permissions for others is read-only. So any user can view the files.

Similarly, for a user in "OPQ" group, they should be able to read "data1" file, but why can he do that while he doesn't belong to "XYZ" group at all


A user can belong to multiple groups. Also, there is nothing blocking users from the directory -- everyone has read access to the directory. Group and Other don't have "x" permission on the directory which mean they can't enumerate the files in the directory. But if given the file name, they can read the file.
[ November 27, 2006: Message edited by: Scott Johnson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic