LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   User and Group Access to Folders (https://www.linuxquestions.org/questions/linux-security-4/user-and-group-access-to-folders-266591/)

nutthick 12-15-2004 04:51 AM

User and Group Access to Folders
 
I've just been reading about user and group access to folders, but am having a problem understanding a couple of things.

When in Windows, you can assign multiple user and group permission to a file/folder, plus you can allow permissions to propagate through a folders contents. Can I do this in Linux?

From what I can see, I can only assign a single user to a folder/file, but can assign multiple groups. The only way I can see around the first problem is to assign each user their own group, thereby allowing me to provide access based on individual users. Is that the only way to do it, and can you nest groups within groups?

The seconds problem worries me even more. If I set permissions to a folder, are the permissions propagated through the folders contents, including newly added files? From what I've read, I have to individually assign access right to each file as it appears. This must be incorrect, as it sounds crazy. Is it correct and do permissions propagate through folder contents?

Thanks

darthtux 12-15-2004 05:05 AM

If you do an
Code:

ls -l
you will note similar to the following
Code:

drwxr-xr-x
This can be broken down as
d
for directory or - for a file
rwx
permissons for the owner(user) of the file
First r-x
permissions for the group of the file
Second r-x
permissions for everyone else

If change permissions just for a directory, no it's permissions do not propogate down the directory tree. Then, since everything is under the root directory, everything would be owned by root! But if you want to change ownership on a directory and every thing under it, there is an option to the chmod command
Code:

chmod -R user directory
or you can change user and group ownership with
Code:

chmod -R user:group directory
You can't assign multiple groups but you can make a new group with the users you want in that group and then change group ownership of that file/directory with
Code:

chown :group directory/file
or
Code:

chgrp file
or recursively with the -R option

nutthick 12-15-2004 05:15 AM

Thanks darthtux. So if I wanted to assign full access to group1, group2, user1 and user2, the only way to do it would be to create a new group and place all the users from group1 and group2, plus user1 and user2 into it? Have I got that correct, it sounds a nightmare to administer?

nutthick 12-15-2004 05:20 AM

I just did a test assigning 777 -R to a directory. Everything within the it went to 777, but when I copied a file, the file had permission 755. Is there any way to make the copied file take 777 as it's permission?

darthtux 12-19-2004 04:07 AM

If you copy a file that has permissions 755 it will not automatically take permissions 777. You could write a little script like:

#!/bin/bash
cp $1 $2
chown 777 $2/$1

Name it something like "cpperm" and put it in a directory in your PATH. Then on the command line:

cpperm file directory

This puts file in directory and changes its permissions to 777

darthtux 12-19-2004 07:22 PM

Whoops! I made a small mistake. That should have been

Code:

#!/bin/bash
cp $1 $2
chmod 777 $2/$1



All times are GMT -5. The time now is 08:21 PM.