Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Umask difference between 0022 and 022 [closed]

Tags:

Is there any difference between umask 0022 and 022? I want to change my umask to 022. How can I do it?

like image 944
Pavunkumar Avatar asked Nov 07 '12 11:11

Pavunkumar


People also ask

What is umask of 0022?

The default umask 002 used for normal user. With this mask default directory permissions are 775 and default file permissions are 664. The default umask for the root user is 022 result into default directory permissions are 755 and default file permissions are 644.

What will be permission of newly created file if umask is 002?

This is telling us the So if we create a new file, it has the default permissions 664, which is 666 (the default permissions for files) masked by 002 (our umask value). As expected, the new file has permissions -rw-rw-r--, or 0664: The owner and group may read or write the file, and others may only read it.

How umask is calculated?

To determine the umask value you want to set, subtract the value of the permissions you want from 666 (for a file) or 777 (for a directory). The remainder is the value to use with the umask command. For example, suppose you want to change the default mode for files to 644 ( rw-r--r-- ).

Why is my umask 0002?

By default, DataStage uses umask 002 which means new directories will have permission 775 and new files permission of 664. With umask 007, directories will have permission 770 and new files will have permission 660.


1 Answers

There is no difference between umask 0022 and umask 022.

The octal umasks are calculated via the bitwise AND of the unary complement of the argument using bitwise NOT.

Set the umask like this:

el@apollo:~$ umask 0077 el@apollo:~$ umask 0077 el@apollo:~$ umask 0022 el@apollo:~$ umask 0022 

Brief summary of umask value meanings:

umask 077 - Assigns permissions so that only you have read/write access for files, and read/write/search for directories you own. All others have no access permissions to your files or directories.

umask 022 - Assigns permissions so that only you have read/write access for files, and read/write/search for directories you own. All others have read access only to your files, and read/search access to your directories.

umask 002 - Assigns permissions so that only you and members of your group have read/write access to files, and read/write/search access to directories you own. All others have read access only to your files, and read/search to your directories.

For more information about what umask does:

How to set your default umask, see this article: http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html

If you want more detailed information this is an interesting article: http://articles.slicehost.com/2010/7/17/umask-and-unusual-file-permissions-and-types

The answers to this post also offer some insight into umask bits: https://stackoverflow.com/questions/4056912/question-about-umask-in-linux

like image 132
Joakim Nohlgård Avatar answered Sep 22 '22 06:09

Joakim Nohlgård