1

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?

3
  • 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, 2012 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, 2012 at 21:17
  • 1
    FWIW, mktemp, the real "make temporary file" command, will only give permissions to owner.
    – Daniel Beck
    Sep 25, 2012 at 4:59

1 Answer 1

6

[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

You must log in to answer this question.