Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have an odd problem with umask. My current setting is:

$ umask
0022
$ umask -S
u=rwx,g=rx,o=rx

This only works for files though and not directories:

$ touch abc
$ ll abc
0 -rw-rw-rw- 1 user1 group1 0 Dec 12 11:39 abc
$ mkdir def
$ ll -d def
8.0K drwxrwxrwx+ 2 user1 group1 4.0K Dec 12  2012 def

Can anybody suggest why umask is not working for the directory? Any help is appreciated!

This is a new Centos linux system.

Edit: thanks for the comments. As some have pointed out, this doesn't work for files either.

Extra information: This problem only seems to occur on the home directory which is mounted over NFS, and not on local directories. Could NFS be causing the problem somehow?

share|improve this question
    
abc's perm is not right either. it should be -rw-r--r-- –  freestyler Dec 12 '12 at 3:05
    
You're right - thanks for pointing that out. –  Tetsuo Dec 12 '12 at 6:23
    
Can you repeat these tests in the /tmp directory? –  slm Jan 12 '13 at 13:01
add comment

migrated from stackoverflow.com Dec 13 '12 at 3:42

This question came from our site for professional and enthusiast programmers.

4 Answers

The umask is not work at all.

For file, the touch command will create with -rw-rw-rw- and the umask is 0022, then after mask 0666 & ~ 0022. The final permission will be 0644 (-rw-r--r--). So it does not work for file either.

For directory, the mkdir command will create with rwxrwxrwx and the umask is 0022, then after mask 0777 & ~ 0022. The final permission will be 0755 (rwxr-xr-x).

But I do not know why does it not work. Maybe it is the problem of your SHELL.

share|improve this answer
    
Thanks for your comment, you're right - the file is not set correctly either. I'm wondering if NFS is the problem (see edit above), but I don't understand the connection to umask in that regard. –  Tetsuo Dec 12 '12 at 6:22
add comment

I think you're problem is that you have access control list getting applied here as well. Notice the directory, def? It has a trailing '+' which means that there is ACL permissions getting applied here as well. Can you run the command getfacl at your $HOME directory level? This will give us more insight into what's going on.

For example:

% getfacl .
# file: .
# owner: saml
# group: saml
user::rwx
group::rwx
other::r-x
share|improve this answer
add comment

The are umask variants (others commands) for files and directories.

share|improve this answer
2  
This would be a much more helpful answer if you added the names of said variants. –  Shadur Jan 12 '13 at 7:38
add comment

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Directories have execution permission unless you disable it explicitly. Try umask 0033 if that's what you want.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.