07 April, 2015

Setting umask for a user in the GECOS field example

umask is a user related setting in Linux, which specifies, that when creating a new file or directory which permissions will be set.

For the shells users can set the umask with the umask command (what a surprice :-) or they can set the defult value using the same command in the shell init scripts.

But there are other programs (like Samba), which are using the umask and they are not taking into account the changes what users are making after they have logged in into the system.

To change the umask for them as the pam_umask manual says, you need to set the values in the GECOS fields.

But what is GECOS? You can find it in Wikipedia, that it is in the /etc/passwd file, but it may be more difficult to find an example for it. To put it short, the GECOS fields are the 5th element in the passwd file and the fields are separated by comas. In the following example we set the umask for the user test:

test:x:1003:100:Test user,umask=0002:/home/test:/bin/bash

No comments: