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

Re: strange umask behaviour



On (07/11/04 20:13), Ali Alphan Bayazit wrote:
> On Sun, 2004-11-07 at 23:30 +0000, Clive Menzies wrote:
> > a shell script for example?  What actually alerted me to this was
> > a .sh
> > to back-up a file to a series of backup files as an exercise.  But it
> > couldn't seem to create the files.
> >  
> most programs specify their file creation permissions as 666 (except
> maybe linkers)
> so when the mask is applied,
> it is applied on 666 not 777,
> obviously for directories it is different
> 
> you can set umask to 000 so you can see the file creation permissions.
> umask 000
> echo something > test1 
> ls -l test1
> # this is bash's file creation permissions 666
> cp test1 test2
> ls -l test2
> # this is cp's...
> 
> so as you see they should both start with 666 and then mask is applied
Thanks Ali

I searched through my various books and online for such an explanation
to no avail.

Regards

Clive


> 
> if you are using cp for backup, you may want to use cp -p to preserve
> permissions (including execution)
> 
> in that case, if you want to reset some permissions, you should
> explicitly call chmod og-rxw (whatever), as cp sets the permissions
> after file creation (effectively umask is ignored).
> 
> good luck,

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




Reply to: