如何为用户设置 umask 默认值?

How to set umask default for an user?

有人知道如何为用户设置默认的 umask 并强制他们使用它吗?

我想把 umask 0002,例如,放在他的 ~/.bashrc 文件中,但如果我这样做,他们可以更改 umask。

谢谢 ;)

您可以使用 /etc/profile 文件解决此问题。 我在 /etc/profile 末尾添加了以下行。在将它设置为您需要的值后,它将覆盖实际的 umask 命令

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 ~]#