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.

151 questions
0
votes
1 answer

Can I get a callback / do I know when SQLite has created write-ahead log files? I want to chmod them

I have an elevated process and I want to make sure the SQLite files that it creates are readable by other processes. For some reason umask doesn't seem to do what I want (set permissions of sqlite file created by process). I'm using write-ahead…
Joe
  • 46,419
  • 33
  • 155
  • 245
0
votes
1 answer

Changing Apache/PHPs default file permissions

I have an Amazon EC2 server running Redhat. When my PHP CMS creates files they are owned by www-user and has chmod 644. How can I make all files created by Apache and PHP default to 666? I've already tried adding "umask 002" in /etc/init.d/httpd but…
Fredrik
  • 1,741
  • 4
  • 24
  • 40
0
votes
1 answer

PHP chmod function wont work

A wont work problem. I have a XHR file upload to a directory. There is a button the user presses on the site which executes php code. On that code I placed the function chmod($file_name, 0777);. Never mind the security issues, but this is not…
user1464296
0
votes
1 answer

Ubuntu php mkdir

I'm trying to create a directory but I get the wrong permissions everytime it creates the new directory. Permissions on the file creating the folder: rwxr-xr-x Permission on the folder its trying to create it in rwxr-xr-x Both are owned by…
John
  • 1,095
  • 3
  • 15
  • 31
-1
votes
2 answers

My "umask" output is "022"- why can't I execute a file I just created without "chmod"?

I have a brand-new file called ./foo, which looks like this: #!/usr/bin/env bash echo 'Hello world' The output of the umask command looks like so: $ umask -S u=rwx,g=rx,o=rx $ umask 022 Yet, when I try to execute the brand-new file (no chmod…
Richie Thomas
  • 3,073
  • 4
  • 32
  • 55
-1
votes
1 answer

Docker image - set umask for pod started as different user

I am trying to modify the umask value by adding it to my entrypoint script: #!/bin/bash umask 022 /sbin/rsyslogd ENTRYPOINT ["/bin/sh", "-c" , "/var/run/scripts/entrypoint.sh"] However, this doesn't seem to get modified. The pod is started up with…
HollowDev
  • 111
  • 1
  • 8
-1
votes
1 answer

shell command with Ansible playbook doesn't work

I have added to my playbook a small task that should change umask on my linux machine: - name: set umask to 0022 shell: umask 0022 When running the playbook, I can see this task passes successfully: changed: [myHostName] => { "changed":…
jrz
  • 1,213
  • 4
  • 20
  • 54
-1
votes
1 answer

Creating unix file with permission 755 with UMASK

I want to create unix file with permission of 755. if I use umask of 022, the file gets created with 644. Why is that? Why files are not getting created with execute permission? What's the way around?
Brijesh
  • 131
  • 1
  • 1
  • 5
-1
votes
1 answer

How to set different permissions for directories and files using umask and fuse

I use fuse to mount some directories on Ubuntu. The user should have rwx on directories and rw- on files. Now doing this with setfacl is quite easy. Doing setfacl -R -d -m u::rwX,g::rwX,o::--- dir/ does the job perfectly fine. But how to do this…
Aley
  • 8,540
  • 7
  • 43
  • 56
-1
votes
1 answer

Checking the umask in shell script

How do I check if the umask prevents the group bits from being set? My attempt: #!/bin/sh out=$(umask) echo "$out" if (($out & 070) != 0); then echo "$out" echo "Incorrect umask" > /dev/tty exit 1 fi Output: ./test.sh: line 6: syntax…
Jean
  • 21,665
  • 24
  • 69
  • 119
-1
votes
2 answers

Write permission of a file in unix

While assigning permissions to a file with the command: $ chmod +rwx file1.txt Why is it that read and execute permissions are assigned to everybody, but write permission is only assigned to the user?
Kavya Jain
  • 87
  • 1
  • 10
-1
votes
1 answer

How can I set default umask in gnome on Debian-Stretch?

I would like the permissions on files that I create with gnome apps (e.g., gedit and libreoffice) to respect the umask I set. I have set umask to 027 in ~/.profile and /etc/login.defs. I've also followed the directions from here by adding a line to…
user847
  • 123
  • 5
-1
votes
1 answer

umask for internal-sftp in Docker container

I have a rather simple sftp Docker container in which I have the following /etc/ssh/sshd_config, inspired by so many different sources on the Internet – no claims that it's perfect, but hey, it kind of works. Port 22 Protocol 2 HostKey…
Morpheu5
  • 2,610
  • 6
  • 39
  • 72
-1
votes
1 answer

What is the umask 'relative to'?

I understand that the umask is a 'last stage filter' that ensures specific permission bits are set off on newly created files or directories. My question is, what does it operate on? How is the input permission set determined? To illustrate my…
DatsunBing
  • 8,684
  • 17
  • 87
  • 172
-1
votes
1 answer

SFTP upload in FileZilla results in 0000 file permissions

Linux version 2.6.32-504.1.3.el6.x86_64 CentOS release 6.6 I am connecting to the server via SFTP (FileZilla client) with an SSH key as the user that owns the web directory (let's call it fred). When I upload files, they have fred as the file's…
William Beaumont
  • 357
  • 2
  • 6
  • 15
1 2 3
10
11