/etc/skel是一个为新用户克隆的文件夹。是否有可能定义规则从/etc/skel文件夹中复制?
例如,我正在寻找一种方法,如果创建了一个用户并属于名为A的组,那么除了/etc/skel/not_for_a.txt之外,还可以克隆/etc/skel文件夹。有可能吗?
发布于 2017-12-06 05:51:25
注意,useradd命令允许您使用-k选项指定自定义SKEL目录。您可以在没有not-for-a.txt的情况下创建/etc/ SKEL -for- group -A目录,然后将新用户的默认组添加为A,并使用以下命令指定他们的SKEL目录:
useradd username -g groupA -k /etc/skel-for-group-A -m参考:http://manpages.ubuntu.com/manpages/trusty/man8/useradd.8.html
发布于 2017-12-06 13:22:18
adduser确实支持从框架目录中排除文件的有限方法。来自man adduser.conf:
SKEL_IGNORE_REGEX
Files in /etc/skel/ are checked against this regex, and not
copied to the newly created home directory if they match. This
is by default set to the regular expression matching files left
over from unmerged config files (dpkg-(old|new|dist)).虽然不能从命令行设置这个regex,但可以使用--conf选项设置使用的配置文件。因此,您可以创建仅在/etc/adduser.conf上不同的其他SKEL_IGNORE_REGEX副本,并使用这些副本:
(grep -v '^SKEL_IGNORE_REGEX' /etc/adduser.conf; printf "%s\n" 'SKEL_IGNORE_REGEX="not_for_a.txt"') > /etc/adduser_A.txt
sudo adduser --conf /etc/adduser_A.txt ...https://askubuntu.com/questions/983649
复制相似问题