Questions tagged [umask]

umask is a Unix command to specify default permissions for the new files, created by the current user. umask is inverted ( umask 0 = world readable, writeable and executable).

umask is a Unix command to specify default permissions for the new files, created by the current user. umask is inverted ( umask 0 = world readable, writeable and executable).

It is used when multiple users produce some shared data but any user must be capable of overwriting this data.

The default umask is often selected so to 022 (only owner can modify the file but the group and the world can read) or to 002 (owner and group can modify the file, the world can read).

umask accepts the same bitwise mask as chmod command, but it is inverted: it specifies bits that must not be set. For instance

 umask 555
 touch t.tmp
 ls -l t.tmp

will result

 --w--w--w- 1 me 0 2013-01-25 09:11 z.tmp

(444 is the "write only" flag). By concept, the mask serves for removal of permissions (000 - nothing is removed, 777 - all removed).

Regardless of umask, the newly created files may not be executable, for instance on Ubuntu 10.04:

 umask 0
 touch x.tmp
 ls -l x.tmp

will anyway result

 -rw-rw-rw- me 0 2013-01-25 09:36 x.txt

even if the lowest (execute) bit is 0 in umask.

134 questions
102
votes
5 answers

Setting default permissions for newly created files and sub-directories under a directory in Linux?

I have a bunch of long-running scripts and applications that are storing output results in a directory shared amongst a few users. I would like a way to make sure that every file and directory created under this shared directory automatically had…
David Dean
  • 6,985
  • 5
  • 31
  • 41
66
votes
3 answers

How to set system wide umask?

I am working in a lab where we are running Linux (Debian and Ubuntu). Usernames and group names are handled by NIS and yp. We have some common users that everybody has access to that run the experiments and then we each have our own users in…
HansHarhoff
  • 1,787
  • 2
  • 19
  • 32
31
votes
3 answers

How to create Unix Domain Socket with a specific permissions in C?

I have a simple code, like: sockaddr_un address; address.sun_family = AF_UNIX; strcpy(address.sun_path, path); unlink(path); int fd = socket(AF_UNIX, SOCK_STREAM, 0); bind(fd, (sockaddr*)(&address), sizeof(address)); listen(fd, 100); I want to…
abyss.7
  • 12,136
  • 9
  • 44
  • 94
29
votes
5 answers

linux: getting umask of an already running process?

How can I check the umask of a program which is currently running? [update: another process, not the current process.]
Mark Harrison
  • 267,774
  • 112
  • 308
  • 434
24
votes
1 answer

Umask difference between 0022 and 022

Is there any difference between umask 0022 and 022? I want to change my umask to 022. How can I do it?
Pavunkumar
  • 4,717
  • 10
  • 39
  • 67
21
votes
4 answers

Git change default umask when update file

I have a problem with Git. I searched for a solution in Google and in StackOverflow but nothing helps. The problem is that every time git updates some file in the working directory (when I checkout branches or I merge a branch, etc.) then the file…
Roman Gelembjuk
  • 1,501
  • 2
  • 18
  • 44
16
votes
3 answers

set umask for tomcat8 via tomcat.service

I am trying to set a custom umask for a tomcat 8 instance, tried to make it the good way by using the UMask directive in systemd tomcat unit as seen here without luck. I'd like to set a 022 umask cause the company dev needs to access tomcat /…
Pier
  • 408
  • 1
  • 7
  • 16
16
votes
4 answers

How to use os.umask() in Python

I'm trying to set a umask using the os module. Please note my normal umask set in my ~/.profile is umask 0027. In a bash shell, umask 0022 will allow a file to be created with permissions -rw-r--r-- However, when us import the os module and do…
narnie
  • 1,604
  • 1
  • 17
  • 33
15
votes
1 answer

Setting umask in Git / Gitolite

I have set up Git and Gitolite, and at some point I recall having seen an "umask" setting, in one of the configuration files. Does this set the permissions for all files I sync using Git? That is exactly what I need. Where can I find it?
user852091
  • 2,820
  • 5
  • 18
  • 21
14
votes
3 answers

java set file permissions to 777 while creating a file object

Possible Duplicate: How can I set the umask from within java? How do you set file permissions to 777(or any other arbitrary permission) while creating a file object in java?
Abhishek
  • 1,669
  • 8
  • 26
  • 39
14
votes
2 answers

Error after updating npm, cordova

I updated npm and cordova, after which I'm not able to run any of the cordova commands from terminal. Here is the error which I get: Avinash-mac-mini:~ avinash$ cordova module.js:339 throw err; Error: Cannot find module 'umask' at…
Avinash
  • 742
  • 7
  • 17
13
votes
4 answers

Reading umask (thread-safe)

I know this pattern to read the umask in Python: current_umask = os.umask(0) # line1 os.umask(current_umask) # line2 return current_umask # line3 But this is not thread-safe. A thread which executes between line1 and line2 will have a…
guettli
  • 26,461
  • 53
  • 224
  • 476
13
votes
4 answers

How to trace where php5-fpm umask settings are coming from on ubuntu

I'd really appreciate any help in tracking down and diagnosing an umask issue on Ubuntu: I'm running php5-fpm with Apache via proxy_fcgi. The process is running with a umask of 0022 (confirmed by having PHP send the results of umask() into a file…
danielmerriott
  • 441
  • 1
  • 3
  • 9
12
votes
1 answer

Why is the argument of os.umask() inverted? (umask 0o000 makes chmod 0o777)

In most places, permissions are defined as an octal number in the format of 0777. But UNIX's umask command (thus os.umask()) needs 0o000 to produce the permission bits of 0o777 and 0o022 equals to 0o755 in my understanding. I heard that UNIX's umask…
ddinchev
  • 29,115
  • 26
  • 82
  • 124
11
votes
3 answers

Making new files automatically executable?

Is it possible to make all newly created files have the execute permission when they are created? Why can't I grant it by default?
Jurgen Malinao
  • 149
  • 1
  • 1
  • 4
1
2 3
8 9