Understanding Linux umask on Redhat / Centos

umask is linux's way of determining default file/folder permissions when new files and folders are created. It's a little odd in that the umask is subtracted from 777 for folders and 666 for files to get the correct permissions. I don't claim to understand fully, but it just is.

What is your current umask?

umask
0002

By default, normal users will get a umask of 0002 = 775 on a folder and 664 on a file. This equates to

-rwxrwxr--

for a file.

I had a user that had a set umask of 0022, but all other users had a umask of 0002. This puzzled me, I looked in the normal areas that you can override the umask

/etc/profile

and

~/.bashrc

but didn't see anything obvious. Then looking in

/etc/passwd

I noticed this user had a groupid set to apache's group (48). This was done for reasons outside this discussion.

So if a userid or groupid < 99 then umask = 0022 (more restrictive).

Resources:
http://kbase.redhat.com/faq/docs/DOC-1373

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <drupal5>, <drupal6>, <javascript>, <php>, <sql>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options