Re: Set file permission without using chmod or umask??



fazlin <fazlincse@xxxxxxxxx> wrote:

I have a script that does the following:

$ cat myscript

find . -name *.c > /tmp/list
$

My default umask value is 022. So the file is created with 644
permission (assume /tmp/list did not exist before).

I need "/tmp/list" file to have 640 permission. As for as i know,
there are two ways of doing it in linux - using umask before my 'find'
statement (or) using chmod after 'find' statement.

Is there any other way to set my required file permission other than
this?

You can first create an empty file with the right permissions, e.g. using
install -m 640 /dev/null tmp/list


Florian
--
<http://www.florian-diesch.de/>
-----------------------------------------------------------------------
** Hi! I'm a signature virus! Copy me into your signature, please! **
-----------------------------------------------------------------------
.



Relevant Pages

  • Re: [SLE] Sometimes Linux makes me crazy.
    ... > there a site where I can learn more about security on Linux? ... The Unix / Linux concept of the "umask" is probably somewhat obscure, ... The value passed for this permission is typically "maximal" in the sense ... If you're working in a cooperative environment where groups are used to ...
    (SuSE)
  • Re: [SLE] Alert
    ... >>Randall Schulz ... > tell me the effect of doing an umask, as I'm not quite convinced what ... Every time a program creates a file, it specifies a set of permission ... it will usually use 0777 (read+write+execute for owner, ...
    (SuSE)
  • Re: newbee learning linux: how to allow write permission to user on mounted drives
    ... The manual page for mount says: ... I do understand that the umask of a process is used to ... *remove* bits from the permission mask when *creating* files and directories. ...
    (comp.os.linux.setup)
  • Re: umask?
    ... He said, for example, that would be umask 0. ... umask has nothing to do with the permission bits that get ... and the 'other' read, write, and execute flags. ... Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org ...
    (alt.os.linux.suse)
  • Re: umask?
    ... > created in a directory to have group writable permission on them, ... > search to find an explanation of how umask works with all the different ... editing /etc/bashrc (in FC - don't know in SuSE). ... simply set in umask every bit you want to reset in default permission ...
    (Fedora)