Re: File Permissions

Jens.Toerring_at_physik.fu-berlin.de
Date: 10/03/03


Date: 3 Oct 2003 13:41:35 GMT

Stu <beefstu350@hotmail.com> wrote:
> I am running in the ksh and have a umask 000 and my file gets created
> with the permissions of 666.

> -rw-rw-rw- 1 stu developer 0 Oct 3 09:17 x

> Why does it get created as 666. Is this the default behavior of the
> UNIX?, KSH?.

Yes, 666 is some kind of default - you wouldn't like all files to
be created with the execution bit set and you can change the
behavior for the other bits via umask. But perhaps you're misunder-
standing what umask is. Contrary to a quite common believe umask
does not *set* the permissions for a newly created file, it says
which permission bits are *not* to be set. That's wky it's called
'umask' and not just 'mask'. So, by having umask set to 000 you
actually allow all bits to be set for a new file. If you want to
keep the rw bits from getting set for the new file you have to set
umask to 666:

jens@crowley:~ > umask 000
jens@crowley:~ > touch testfile
jens@crowley:~ > ls -l testfile
-rw-rw-rw- 1 jens users 0 Oct 3 15:32 testfile
jens@crowley:~ > rm testfile
jens@crowley:~ > umask 666
jens@crowley:~ > touch testfile
jens@crowley:~ > ls -l testfile
---------- 1 jens users 0 Oct 3 15:33 testfile
jens@crowley:~ >
                                  Regards, Jens

-- 
      _  _____  _____
     | ||_   _||_   _|        Jens.Toerring@physik.fu-berlin.de
  _  | |  | |    | |
 | |_| |  | |    | |          http://www.physik.fu-berlin.de/~toerring
  \___/ens|_|homs|_|oerring


Relevant Pages

  • Re: umask?
    ... setgid permissions used on your files and directories. ... the default umask value set on your system to 027, ... The shell does simple maths to determine what permissions are used on ... On a directory the maximum permissions will be drwxrwxrwx. ...
    (Fedora)
  • Re: [patch 12/13] ACL umask handling workaround in nfs client
    ... >> the umask locally, and sends the effective permissions to the server. ... >> only the default ACL determines the file's effective permissions. ...
    (Linux-Kernel)
  • Re: default permissions when scping files
    ... >> username take on specific permissions, or barring that, ... I read it to mean that the umask does not affect the execute bit of files ... as the source file has. ...
    (comp.unix.shell)
  • Re: File Permissions problem : Cry for HELP
    ... is something wrnog with the server cause when i upload the same files from ... >> i have a problem with file permissions, each new file i need to create i ... >> Internal Server Error ... > You need to change the umask used when you are saving web files. ...
    (Fedora)
  • RE: how to open a file with 666 permission
    ... > You need to set umask to 0 before creating the file. ... Or use chmodon the file to set whatever permissions you desire. ... The information contained in this electronic message and any attachments to this message are intended ... you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately ...
    (perl.beginners)