[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Automatically maintaining permissions on specific directories



On (18/09/05 01:39), Olle Eriksson wrote:
> Is there any way to enforce the permissions on a specific directory so 
> that everything that is in it will always have the correct permissions?
> 
> I know a simple cron job can do the job but I have fucked up more file and 
> directory permissions than wanted on more than one occasion this way. And 
> also, it would be nice to know that any files moved to a certain 
> directory (like public_html) will get the correct permissions instantly 
> without having to issue a chmod command or wait for the cron job to 
> finish.
> 
> I used to have a partition with the FAT32 filesystems, which allows you to 
> set global values for user id, group id and permissions (with uid, gid, 
> umask, dmask and fmask). Then, all files moved to this filesystem would 
> get the specified permissions automatically. A while ago I switched to 
> XFS because I needed to be able to have files larger than 2 Gb, and XFS 
> doesn't have these features.

When I asked this question, someone posted something like this:

Prepare a directory hierarchy for group use, do the following as
root:
# chgrp -R $group $dir
# find $dir -type d -print0 | xargs -0 chmod 2770
(You can use mode 2775, depending on needs for further information see
'man chmod' and google on Linux permissions)

# sudo find $dir -type f -print0 | xargs -0 chmod 660
(likewise, you may also use mode 664...)


An alternative to the above is:
# sudo find $dir -type f -print0 | xargs -0 chmod g=u,o=-rwx
This will clear permissions for others and set group permissions to the
user permissions. This will preserve executable permissions.  Give
yourself membership of the various groups to test permissions,
ownership, etc.
					
Regards

Clive

-- 
www.clivemenzies.co.uk ...
...strategies for business




Reply to: