Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Where do the default values of 666 and 777, for files and directories respectively, get stored?

umask 0002
touch dummy 
ls -l 

Tells me that dummy's permissions are 700 as opposed to the expected 644. Any ideas?

share|improve this question
    
It doesn't seem like umask is doing anything. Even after setting umask to 100, and then making a temp file, I still get 700 as my permissions. –  aafc Sep 24 '12 at 20:52
5  
What kind of file system is this? If it's a FAT/vFAT filesystem that doesn't understand the full set of permissions, then the actual results you get will depend more on mount options than on umask. –  twalberg Sep 24 '12 at 21:17
    
FWIW, mktemp, the real "make temporary file" command, will only give permissions to owner. –  Daniel Beck Sep 25 '12 at 4:59
add comment

migrated from stackoverflow.com Sep 25 '12 at 4:29

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

1 Answer

[max@localhost ~]$ umask

This will display default umask

0002

In /etc/bashrc file default permissions are stored

 16 if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
 17     umask 002
 18 else
 19     umask 022
 20 fi

The default umask for normal user 002

The default umask for the root user is 022

For directories, the base permissions is 0777 and for files 0666

That means if you set umask value to 002 then you subtract the umask from the base permissions

For Directories

777-002=775

For files

666-002=664

[max@localhost ~]$ mkdir file1

[max@localhost ~]$ ls -ld file1

drwxrwxr-x 2 max max 4096 Sep 25 15:37 file1 ------>775

[max@localhost ~]$ touch file2

[max@localhost ~]$ ls -l file2

-rw-rw-r-- 1 max max 0 Sep 25 15:40 file2------->664

share|improve this answer
add comment

Your Answer

 
discard

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