LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   stuck in file permissions (https://www.linuxquestions.org/questions/linux-newbie-8/stuck-in-file-permissions-682012/)

raj_hcl1986@rediffma 11-08-2008 02:55 PM

stuck in file permissions
 
Hi
I m new in linux and have a basic query. Hope i ll get my answer here.

I have made a file /depts/hr/ in root's home directory. Now changed its group ownership from 'root' to 'hr'. Also changed the file permissions of /depts/hr to 770.

Now I want to access this file with ls from a user 'atul' who is also a member of 'hr' group. But when i do this i m getting error- permissioned denied.

Isn't it correct that with above given permissions members of group can access the file? Then why atul is not able to?

Pls guide me.

BlueC 11-08-2008 04:01 PM

Probably because atul is not allowed access to /root and depts/hr is within /root

If you want to set up a directory that other users have access to then do not put it in /root because no other user should have access to /root

I would put the depts/hr directory in /usr/share/ and then set the permissions/ownership accordingly.

i92guboj 11-08-2008 04:06 PM

Quote:

Originally Posted by raj_hcl1986@rediffma (Post 3335571)
Hi
I m new in linux and have a basic query. Hope i ll get my answer here.

I have made a file /depts/hr/ in root's home directory. Now changed its group ownership from 'root' to 'hr'. Also changed the file permissions of /depts/hr to 770.

Instead of providing the straight answer, I will show you the patch to enlightenment so hopefully you learn it better :)

I assume that depts/hr is under /root then. Right?

In that case, try these three commands, and look carefully the ownerships and permissions for the three commands:

Code:

ls -ld /root
ls -ld /root/depts
ls -ld /root/depts/hr

All of these as root, for obvious reasons since your regular users will not be able to do so.

The hint: note that to be able to reach "hr" you need to go across all the possible locations between / and that location. If there's a wall in the middle of the road then you can't pass.

raj_hcl1986@rediffma 11-08-2008 04:46 PM

Thanks to both of you for providing valuable info. But still have doubt that if I make my file in /usr/share then it has permissions rwxr_xr_x means atul can only see the files inside but cannot create a new file. Where to make a file which is accessible to all and everyone can write.

Is /tmp OK ?

i92guboj 11-08-2008 11:26 PM

Quote:

Originally Posted by raj_hcl1986@rediffma (Post 3335631)
Thanks to both of you for providing valuable info. But still have doubt that if I make my file in /usr/share then it has permissions rwxr_xr_x means atul can only see the files inside but cannot create a new file. Where to make a file which is accessible to all and everyone can write.

Is /tmp OK ?

tmp is ok, but there's no reason why you can't write into a directory under /usr/local if you set it +w for your user/group. It really depends on what that file is going to contain. Note that the contents of tmp is wiped on reboots by default on some distros.

The read and exec permissions for directories are somewhat different on that matter, because to access a subdir you need to read the dirs that are before it on the tree. But to write into a dir, you don't need to write anything on the father dirs.

So, as long as you have +rx on the previous dirs, you can allow +w on a given dir and it should work.


All times are GMT -5. The time now is 12:27 PM.