gpt4 book ai didi

linux - 通过命令行创建具有不同配置文件的 Linux 用户

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:50:19 26 4
gpt4 key购买 nike

我想知道在 Linux 中添加用户时是否可以覆盖 SKEL 属性。

手册页为我提供了动态更改任何属性(SHELL、HOME 等)但不包括 SKEL 的所有内容。

我想做的是找到一种方法来为我正在创建的用户分配一个或另一个配置文件。

例如,我需要创建一个具有 .profile 的用户,其中 VAR=value1,以及另一个具有 .profile 的用户其中 VAR=value2。我的想法是创建不同的 SKEL,一个用于需要 VAR=value1 的人,另一个用于需要 VAR=value2 的人,然后简单地执行 adduser ... - D -magic_option/SKEL/for/value1adduser ... -D -magic_option/SKEL/for/value2。但是-magic_option好像不存在。

有什么建议吗?

最佳答案

当然,只要在useradd中使用-k选项即可:

-k, --skel SKEL_DIR

The skeleton directory, which contains files and directories to be copied in the user's home directory, when the home directory is created by useradd.

This option is only valid if the -m (or --create-home) option is specified.

If this option is not set, the skeleton directory is defined by the SKEL variable in /etc/default/useradd or, by default, /etc/skel.

If possible, the ACLs and extended attributes are copied.

因此您可以创建您的 /my/skel_for_users/my/other_skel_for_users 并在创建一个时使用它们中的任何一个。

关于linux - 通过命令行创建具有不同配置文件的 Linux 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33543235/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com