file permissions

Alan McKinnon alan at
Mon Sep 11 14:07:35 UTC 2006

On Monday 11 September 2006 15:34, Zoltan Szecsei wrote:
> Alan McKinnon wrote:

> > Ok, let's back up a little then and get some facts to work
> > with:
> >
> > With what options is the target filesystem mounted, and
> > what fs?
> ext3
> > What umask is in effect?
> the default umask 022 in .bash_profile is commented out
> root at gl0:/home/zls# cat /etc/login.defs  | grep -i ask
> #       UMASK           Default "umask" value.
> # UMASK usage is discouraged because it catches only some
> classes of user # umask in shell rc file will catch also
> logins through su, cron, ssh etc. # At the same time, using
> shell rc to set umask won't catch entries which use
> # Therefore the use of pam_umask is recommended (Debian
> package libpam-umask)
> # This avoids the confusion created by having the umask set
> # 022 is the "historical" value in Debian for UMASK when it
> was used #UMASK          022
> UMASK           002
> # Other former uses of this variable such as setting the
> umask when
> > What happens when the umask is changed to 0066?
> I changed it in /etc/login.defs and it seemed to have no
> effect. (but then I get into gl0 using putty from my WinXP
> box)
> I need a way to force all files in a directory to keep their
> 775 permissions regardless of who puts the file into that
> directory, and regardless of how that user logged into the
> system and regardless of whether the file originated from
> another host or not.

That's cool, but you didn't answer two of my questions. We both 
know how umask is supposed to work, what we don't know is why 
it isn't doing that on your machine.

Which 4 numbers are printed to the console when you run 
the 'umask' command in a shell? And what are the mount options 
and fs type of the filesystem in question? If you touch a new 
file there, what permissions does it have - are they set right 
at first, then something else changes them after two seconds 

If all else fails:

Step 1 is to realise that what you want is completely contrary 
to the design of the ext2/3 & reiser filesystems - these put 
responsibility for settings permissions totally under the 
user's control, so there isn't a way to ensure that a certain 
permission will be set.

Then, 775 seems odd - are these all executable files? There is 
no way I know of the create a new file and have any of the 
execute bits set. The kernel applies a hard coded MODE of 0666 
to new files, modified by the umask. To set x, one has to run 
chmod. But no matter, this doesn't change the principle 

I assume you want the files to start with 775 and to never 
change to something else. I can think of a few workarounds:

1. Use the affs or adfs file system types, these have a mode 
option per the man page

2. Hook into some daemon like fam and chmod all new or changed 
files as they are changed

3. Run 'find -perm -exec chmod' every few minutes in a cron

4. Run 'chmod -R 775 /path/to/dir/*' every minute

5. Place the directory under discussion on a vfat file system. 
Mount it using an appropriate combination of exec, umask, 
fmask, dmask, uid and gid options. This satisfies local users. 
Share this dir using samba and enforce the permissions you 

Hopefully one of these suits your needs.


> Zoltan
> > alan
> --
> ===========================================
> Geograph (Pty) Ltd.
> P.O. Box 31255, Tokai 7966, South Africa.
> B3-106 Tokai Village, cnr Vans/Tokai Rds,
> Tokai 7945, Western Cape, South Africa.
> Tel: +27-21-7154329  Mobile: +27-83-6004028
> Fax: +27-86-6115323
> ===========================================

More information about the ubuntu-users mailing list