G.W*_*.W. 6 permissions .profile umask gnome-session 17.04
过去,我一直设置umask
为~/.profile
。我设置了一个umask
,077
所以我的文件获得了600 (rw-------)
. 但是~/.profile
在 Ubuntu 17.04 中将其设置为不再有效。
因此,当在 Ubuntu 17.04 上的 gnome 会话中创建新文档时,我可以在哪里配置以便使用权限 600 创建它们?
为任何用户创建的所有目录和文件设置权限:
新文件将为 600。新目录将为 700。
TL; dr:在文件中替换UMASK 022
为eg ,但不能100%工作。UMASK 027
/etc/login.defs
有关这方面的信息,请参阅手册页 (20.04) 。有几个地方可以设置它:我过去使用过/etc/pam.d/login
or但停止工作,所以现在我正在使用which部分工作。/etc/default/login
/etc/login.defs
\n\nPAM 模块尝试按以下顺序从以下位置获取 umask 值:
\n\xc2\xb7 umask= 用户 GECOS 字段中的条目
\n\xc2\xb7 umask= 参数
\n\xc2\xb7 /etc/login.defs 中的 UMASK 条目(受 /etc/login.defs 中的 USERGROUPS_ENAB 影响)
\n\xc2\xb7 UMASK= /etc/default/login 中的条目
\n(...)
\n例子
\n将以下行添加到 /etc/pam.d/login 以在登录时设置用户特定的 umask:
\nRun Code Online (Sandbox Code Playgroud)\nsession optional pam_umask.so umask=0022\n
在文件中/etc/login.defs
,有一个条目UMASK 022
可以替换为(在我的例子中)UMASK 027
。然后重新启动。这产生:
$ umask\n0022\n$ more /etc/login.defs | grep ^UMASK\nUMASK 027\n\n$ echo foo > terminal\n\nNOTE: Open gedit from Dock and write file `dock`\n Open gedit from Menu and write file `menu`\n\n$ ls -l dock menu terminal\n-rw-r--r-- 1 daniel daniel 4 nov 4 16:11 dock\n-rw-rw---- 1 daniel daniel 4 nov 4 16:11 menu\n-rw-r--r-- 1 daniel daniel 4 nov 4 16:11 terminal\n
Run Code Online (Sandbox Code Playgroud)\n$ umask\n0007\n$ more /etc/login.defs | grep ^UMASK\nUMASK 027\n\n$ ls -l foo bar\nls: cannot access \'foo\': No such file or directory\nls: cannot access \'bar\': No such file or directory\n\n$ touch foo\n$ echo hello > bar\n$ ls -l foo bar\n-rw-rw---- 1 daniel daniel 6 nov 4 17:20 bar\n-rw-rw---- 1 daniel daniel 0 nov 4 17:20 foo\n
Run Code Online (Sandbox Code Playgroud)\n请注意,我的 Ubuntu 版本上不存在此文件,在这种情况下我们可以创建它。
\n$ sudo sh -c "echo \'session optional pam_umask.so umask=0027\' >> /etc/default/login"\n\n$ more /etc/default/login\nsession optional pam_umask.so umask=0027\n
Run Code Online (Sandbox Code Playgroud)\n现在,如果我们重新启动并在终端中询问 umask,我们仍然会得到0022
(在 Ubuntu 18.04 的情况下),而不是0027
设置的值。请参阅错误#1685754。
但是,如果我们打开一个应用程序(例如文本编辑器)并保存文件,我们会注意到新的 umask 影响的权限。umask
从菜单打开它,而不是从终端打开,因为它似乎从终端中获取(坏) 。
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
Run Code Online (Sandbox Code Playgroud)
这就是你~/.profile
所说的字面意思。更改后是否重新登录?它应该工作正常。
还:
This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login exists.
Run Code Online (Sandbox Code Playgroud)
实际上在新安装的 ubuntu 17.04 上证实了这个问题。即使完全更新仍然会导致此问题出现,甚至~/.bash_profile
被忽略,命令解释器似乎在登录后不读取这些文件的问题。
~/.bashrc
您现在可以使用,它仍然可以正常工作并在登录期间读取。
因此,在深入研究之后,bash 似乎不再默认使用 --login 运行,这意味着它不会读取 ~/.profile。使用 ~/.profile 中的 umask 启动新的 bash,并bash --login
正确设置 umask 启动没有它的 bash,但会忽略 ~/.profile。不确定改变了什么,但这对我来说似乎是一个错误,除非是故意改变的。
如果您使用 GDM,它的读取方式~/.profile
与 LightDM 不同。并且终端通常会打开一个非登录 shell。最终效果是,~/.profile
当您使用 GDM 登录后打开终端时,根本不会加载。
任何一个:
~/.bashrc
, 或 归档时间: |
|
查看次数: |
15858 次 |
最近记录: |