Set default umask for users when they login?


7 posts
by sliddjur » Thu Sep 13, 2012 3:24 pm
Hello, I need some help setting the default umask for a user when they log in.

I tried to set umask 0002 in gecos field. Doesnt work.
I tried to change in /etc/login.defs. Doesnt work.

Still default 0022 when they login.
Need some help here.
Posts: 5
Joined: Fri Aug 10, 2012 10:28 pm
by Licaon_Kter » Thu Sep 13, 2012 3:27 pm
use umask in /etc/fstab ( man fstab ? )
BFQ+BFS or RT on a RPi? 4'real: https://github.com/licaon-kter/ (source and compiled!)
User avatar
Posts: 240
Joined: Wed Sep 05, 2012 10:12 am
Location: Between the keyboard and the chair.
by wamiduku » Tue Nov 06, 2012 11:15 pm
Licaon_Kter wrote:use umask in /etc/fstab ( man fstab ? )


I have the same problem and tried umask in fstab,
Code: Select all
proc            /proc           proc    defaults                     0       0
/dev/mmcblk0p1  /boot           vfat    defaults                     0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime,umask=0007             0       1


Doesn't work. It makes the file system read-only, which took an awful lot of googling to get out of, but no effect on umask which was still 0022. Any other way to fix the umask problem?
Posts: 3
Joined: Tue Nov 06, 2012 10:49 pm
by Joe Schmoe » Tue Nov 06, 2012 11:38 pm
How about the obvious - set it in /etc/profile?
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2799
Joined: Sun Jan 15, 2012 1:11 pm
by wamiduku » Wed Nov 07, 2012 12:00 am
The /etc/profile file states that you shouldn't set it there:
/etc/profile wrote:# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.
Posts: 3
Joined: Tue Nov 06, 2012 10:49 pm
by jojopi » Wed Nov 07, 2012 8:42 am
That comment does not say that umask should not be set in /etc/profile, only that it is not.

For pam_umask to work, it would have to be mentioned somewhere in /etc/pam.d/, and it is not. So:
Code: Select all
echo "session optional pam_umask.so usergroups" |sudo tee -a /etc/pam.d/common-session
The "usergroups" argument may be sufficient for your purposes without changing login.defs, gecos, etc.
User avatar
Posts: 2122
Joined: Tue Oct 11, 2011 8:38 pm
by wamiduku » Wed Nov 07, 2012 11:09 am
jojopi wrote:That comment does not say that umask should not be set in /etc/profile, only that it is not.

So I just tried setting it in /etc/profile, and to my surprise it actually worked. Thanks!
Posts: 3
Joined: Tue Nov 06, 2012 10:49 pm