Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want the umask to be more permissive for users when they switch to a non-default group. Just to demonstrate what I mean:

$ id
uid=500(beamin) gid=500(beamin) groups=10(wheel)

$ umask

$ sg wheel

$ umask # I want this to now be 0002 instead

I was thinking of adding a script to /etc/profile.d/ that would look like this:

if [ "`id -u`" -ge 500 ] && [ "`id -g`" -ne "`id -u`" ]; then
   umask 0002

I got 500 because all our user uids are larger or equal to that. Is this the best way to do it? Or does someone have something that makes more sense?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I think your solution is fine. In a shell script you can use:

(umask 022;exec sg wheel )

Test with:

umask 002
( umask 022; exec sg wheel umask)

For an alternative solution see my similar post: How do I set permissions structure for multiple users editing multiple sites in /var/www on Ubuntu 9.10?

share|improve this answer

You could create a script mysg that executes sg arg followed by umask X where X is either 002 or 022 depending on which group was entered. Probably not the most elegant solution...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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