1

I typed out the command chfn -o umask=002 souser and expected that souser user would create folders with 775 permission then but he did not. How to get that each new folder created by a certain user would have write permission for the group? Here you are my test:

s@lokal:~$ sudo adduser souser
Adding user `souser' ...
Adding new group `souser' (1002) ...
Adding new user `souser' (1002) with group `souser' ...
The home directory `/home/souser' already exists.  Not copying from `/etc/skel'.
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for souser
Enter the new value, or press ENTER for the default
  Full Name []: 
  Room Number []: 
  Work Phone []: 
  Home Phone []: 
  Other []: 
Is the information correct? [Y/n] y
s@lokal:~$ sudo usermod -aG sudo souser

s@lokal:~$ su souser
Password: 
souser@lokal:/home/s$ cd
souser@lokal:~$ mkdir test
souser@lokal:~$ ls -ld test/
drwxr-xr-x 2 souser souser 4096 Sep  3 14:23 test/

souser@lokal:~$ chfn -o umask=002
chfn: Permission denied.
souser@lokal:~$ sudo chfn -o umask=002 souser
souser@lokal:~$ mkdir test2
souser@lokal:~$ ls -ld test2
drwxr-xr-x 2 souser souser 4096 Sep  3 14:24 test2
souser@lokal:~$ sudo cat /etc/passwd |grep souser
souser:x:1002:1002:,,,,umask=002:/home/souser:/bin/bash
souser@lokal:~$ 

Update #1

After relogin is the same:

souser@lokal:~$ mkdir test3
souser@lokal:~$ ls -ld test3
drwxr-xr-x 2 souser souser 4096 Sep  3 14:42 test3
souser@lokal:~$ 

Update #2

This also did not help:

s@lokal:~/Dropbox$ su - souser
Password: 
souser@lokal:~$ mkdir test4
souser@lokal:~$ ls -ld test4
drwxr-xr-x 2 souser souser 4096 Sep  3 14:51 test4
souser@lokal:~$ 

NOTE: The distro is Debian 9.

2

The possibilities to set umask's strongly differ between Linux and Unix distro's.

The way you are trying to do it (in the "gecos" field in /etc/passwd) depends on pam_umask being installed and configured. AFAIK this is at least the case by default on Debian and probably distro's based on Debian like Ubuntu, Mint, etc...

Without pam_umask, you could put a line umask 002 in the shell's profile or rc-file in the users home directory (e.g.: .bashrc or .profile). Or something like this in the system-wide config file, e.g. /etc/profile (for sh, and bash) or /etc/bashrc (for bash only):

if [ "$USER" = "souser" ] ; then
    umask 0002
else
    umask 0022
fi

You can check if it was successful either way with just a plain umask command which will output the current effective umask.

Note that it is still up to the application to actually set the permissions. If you use some other program or command which in its code hardwires to never set group write permissions on folder it creates, you'll either have to change the code of that program or set permissions manually afterwards. That is just the way UNIX/Linux is supposed to work.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.