M HYPE SPLASH
// general

I get 700 when I make a test file, but umask is 0002? Why isn't it 664 ?

By Emma Terry

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

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy