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
10
votes
3 answers

Setting the umask of the jenkins process

Our jenkins CI server (v1.499) runs tests that call URLs on the CI machine. The applications behind those URLs change the same temporary files as the unit test processes change, so those files need to be group writable. I fixed that for apache…
cweiske
  • 27,869
  • 13
  • 115
  • 180
9
votes
4 answers

When is umask() useful?

umask(0); fd = open("/dev/null", O_RDWR); Here's man 2 umask: umask() sets the calling process’s file mode creation mask (umask) to mask & 0777. But it doesn't make sense for me,as when we call open ,we will also provide a mode parameter. So…
cpuer
  • 6,413
  • 13
  • 32
  • 38
9
votes
7 answers

Unable to load JNA native support library Elasticsearch 6.x

I have installed Elasticsearch 6.x in my Debian 7 (wheezy). I tried to start with service elasticsearch start but its give me an error message root@debian:~# sudo -i service elasticsearch start [FAIL] Starting Elasticsearch Server: failed! I tried…
Gagantous
  • 690
  • 4
  • 21
  • 50
8
votes
2 answers

How to create directory with right permissions using C on Posix

I am trying to write a simple C program that creates directories (a mkdir clone.). This is what I have so far: #include #include // mkdir #include // perror mode_t getumask() { mode_t mask = umask(0); umask…
yasar
  • 11,262
  • 26
  • 80
  • 154
5
votes
2 answers

PHP mkdir() and fopen() does not work - permissions problem? umask problem?

The following PHP script fails to create the directory. It will also fail to create the file (when the directory already exists). ini_set('error_reporting', E_ALL); define('ABSPATH', $_SERVER['DOCUMENT_ROOT']); echo ABSPATH . '
matthewpavkov
  • 2,848
  • 4
  • 19
  • 37
5
votes
3 answers

error cannot find module 'umask'

I just installed nodejs x64 on my Windows 10 computer. I keep all default config, I open cmd and type: npm -v Then i got following error: module.js:457 throw err; ^ Error: Cannot find module 'umask' at Function.Module._resolveFilename…
5
votes
1 answer

Midnight commander does not respect umask

When I create new file in Midnight commander and save it (Shift+F4, write something, F2, name the file), it is created with 640 pemissions even thought my umask is set to 0007 so it should be created with permissions 660. Is there any secret place…
gorn
  • 4,390
  • 6
  • 28
  • 43
5
votes
1 answer

Reading default FileMode when using os.O_CREATE

I'm new to Go, have a bit of a problem with reading default file permissions / system mask. Of course I can specify fixed permissions: f, err := os.OpenFile(fpath, os.O_CREATE|os.O_WRONLY, 0600) But I would like the program to behave nicely and…
LetMeSOThat4U
  • 5,125
  • 4
  • 33
  • 76
5
votes
1 answer

linux umask for sudo and apache

I want to make 002 the system-wide umask for all users (in Ubuntu). I managed to do so for all regular users using the instructions provided by @ephemient (From this post, thanks for that!). However I got 2 more problems. Firstly, when sudoing, the…
user1834095
  • 4,352
  • 2
  • 16
  • 37
5
votes
2 answers

How to set default permissions for new files created with php

Hi I am running a centos server and I want to know how I can set the default chmod of a newly created file that is created by php like fopen. At the moment it is doing 644 but I want 666 so where can I specify this setting?
user550
  • 308
  • 1
  • 5
  • 11
5
votes
3 answers

Set Different Umask For Files And Folders

I am writing a bash script to update some files/directories and I want to run umask in the script to set default permissions for files/directories created by the script. I know I can umask to set the permissions for both files and directories…
cryptic ツ
  • 14,653
  • 9
  • 49
  • 77
4
votes
2 answers

apache and sftp permissions for wordpress automatic update in ubuntu

It's my first time trying to set up Wordpress or any website on a cloud hosting. I am on Ubuntu server, and Wordpress is located in var/www/mydomain/public folder. What I want to achieve is this: Both Wordpress (PHP) and SFTP users can access and…
ragulka
  • 4,152
  • 7
  • 41
  • 71
4
votes
1 answer

File creation mode mask

I'm struggling to understand why would a Unix daemon set the file creation mode mask to 0. I'll be thankful if someone can demystify the umask function.
mrk
  • 2,811
  • 1
  • 24
  • 28
4
votes
2 answers

What causes git's post-receive umask to be different from the user's umask?

After some digging and help here from other people, I found out that I have a problem with the umask setting in git. What I want to achieve is that any git repo that is being checked out on my server, that the umask setting defaults to 0002. I don't…
user32421
  • 679
  • 1
  • 6
  • 14
4
votes
2 answers

umask setting changes after cd

I've got something odd to report. On my newly configured RHEL5 server my shell is set to /bin/bash I have umask set to 002 in .bashrc. When I first log in, umask appears to work correctly: $ touch a $ ls -l a -rw-rw-r-- etc..... if I create…
cshehadi
  • 101
  • 4
1
2
3
8 9