3

Does anybody know how can I set an umask by default for an user and force them to use it?

I think put umask 0002, for example, in his ~/.bashrc file but if I do that, they can change umask.

Thanks ;)

jww
  • 97,681
  • 90
  • 411
  • 885
  • 1
    This question appears to be [off topic](http://stackoverflow.com/help/on-topic). – Jørgen R Jun 10 '15 at 09:16
  • One of the server or unix based Q&A sites like http://serverfault.com might be more suited for this Q. See the links in the footer of SO. – Risadinha Jun 10 '15 at 09:30
  • As an administrator you should set the `umask` for your users in `/etc/profile`. They can still override it in their `~/.bashrc` (which is usually ok since they have to write it actively themselves). If you don't want them to be able to run `umask` manually, block it (revoke their execute permissions). – ArnonZ Jun 10 '15 at 09:35
  • umask is a builtin. You can't change its permissions. – rojomoke Jun 10 '15 at 15:33

1 Answers1

2

You can make a work around for it by using /etc/profile file. I added the following lines at end of /etc/profile. It will overwrite the actual umask command by after setting it the value which you require

umask 0002
alias umask='echo umask cannot be changed'
enable -n umask


[root@client1 ~]# umask
umask cannot be changed
[root@client1 ~]# \umask
-bash: umask: command not found
[root@client1 ~]#
Sriharsha Kalluru
  • 1,743
  • 3
  • 21
  • 27