每个用户主目录中的默认文件

每个用户主目录中的默认文件

我使用的是 ubuntu 服务器 14.04。每当创建用户帐户时,我想默认在每个用户的主目录中添加一些文件和文件夹。

答案1

您可以添加要添加到目录的文件/etc/skel

$ sudo touch /etc/skel/test.txt
$ sudo useradd -m test
$ ls /home/test
test.txt

man useradd

-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.

相关内容