1833790 Members
2936 Online
110063 Solutions
New Discussion

Directory permissions

 
SOLVED
Go to solution
Nilton Eliot Medina Ygr
Occasional Advisor

Directory permissions

Hello,
I am tryng to grant rwx permissions specifically to one user.
I found ACL could do the work, but when doing so (setcl) it gives the permissions to the directory but only on new files and directories. The prmissions for the older ones stay the same.
The idea is that this user can rwx on all subdirectories and files (old and new ones)

What should I do?

Thanks in advance

Nilton Medina Ygreda
IT Systems
SENATI
Lima, Per
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: Directory permissions

Some kind of action will be required on pre-existing files to make this user able to use them rwx

I'd kind of have to know what the users groups were to recommend an exact course of action.

It might be as simple as a chmod -R command -R for recursive on subdirectories.

It might be more complex. More details needed to provide better help.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Sridhar Bhaskarla
Honored Contributor

Re: Directory permissions

Hi Nilton,

Look at the man page of 'acl'.
//An ACL entry prefixed with d: or default:, can only occur in a directory's ACL, and it indicates that the remainder of the entry is not to be used in determining the access rights to the directory, but is instead to be applied to any files or subdirectories created in the directory//

You will need to manually set the permissions to the existing files. Use 'find /directory |xargs setacl ...' to set the permissions for the existing files/directories.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Nilton Eliot Medina Ygr
Occasional Advisor

Re: Directory permissions

Hi,

Well I guess giving permissions manually would be really a great job since there are 15 sub directories to include. Beisdes, The idea is to give permissions only to one user, not all the "others" so maybe chmod is not a good choice (or yes?).

The scenario goes like this
Directory structure:
/d1/s1/ABC
/d1/s1/ABC/ss1 ... /d1/s1/ABC/ss1/dsd1 ...
/d1/s1/ABC/ss2 ... /d1/s1/ABC/ss1/dsd2 ...
/d1/s1/ABC/ss3 ... /d1/s1/ABC/ss1/dsd3 ...

The instruction I used was:
# setacl -m u:userx:rwx d1/s1/ABC

The user "userx" belongs to the "users" group

After the instruction above, userx is able to rwx at "/d1/s1/ABC" but only can create new files/directories (or delete them), but cannot write or delete on the other subdirectories or files already existing.

Again, thanks in advance an thanks for your time.

Nilton Medina Ygreda
IT Systems
SENATI
Lima, PerÃ
Sridhar Bhaskarla
Honored Contributor

Re: Directory permissions

Hi Nilton,

Setting permissions manually is not a difficult job. Just use 'find' command as I mentioned before.

find /your_directory|xargs setacl -m u:userx:rwx

Check to see if the permissions have been set correctly.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Nilton Eliot Medina Ygr
Occasional Advisor

Re: Directory permissions

ok, Sri, I will try it later an I will let you know.
Please ... wish me good luck

thanks,

Nilton
Steven E. Protter
Exalted Contributor

Re: Directory permissions

chown -R seems to be a reasonable way to go, it does subdirectories.

You could compile a list of subdirectories.

dir *. will get a list of direcectories in a the current directory.

ls -alr | grep dr

Will get a list of directories including what you want to change.

You can process the list with awk.

ls -alr | grep dr > /tmp/filelist

cat /tmp/filelist | `{print $8}` > /tmp/file2

while read -r filename
do
chmod ### $filename
done < /tmp/file2


replace ### with the permissions you want.

Saves time.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Bill Hassell
Honored Contributor
Solution

Re: Directory permissions

And remember that write-ownership for a directory has to do with the existence (or removal) of files, while write-ownership for a file has to do with the content. If you just want the single user to own the directories and files, then use chown -R followed by chmod 700 for directries and 600 for files. Since the permissions are different, use find -type to select files or directories.

Be VERY careful with find and chown -R!!! An accidental symbolic link might connect a current directory into another. Do this task as root and it's possible ruin the entire system. Verify exactly what files will be affected by using find without the -exec option to get a list first.


Bill Hassell, sysadmin