首页 > 技术文章 > Linux创建用户时让每个用户家目录中自带说明文档

bpzblog 2020-07-13 00:35 原文

新用户创建时模板文件放在/etc/skel中,只要在skel中放入相应文档,即可在创建用户时在其家目录中产生对应文档

[00:30:48 root@C8[ ~]#ll -a /etc/skel/   ##在skel中新增.Welcome文件
total 24
drwxr-xr-x.   2 root root   95 Jul 13 00:30 .
drwxr-xr-x. 103 root root 8192 Jul 12 23:42 ..
-rw-r--r--.   1 root root   18 Nov  9  2019 .bash_logout
-rw-r--r--.   1 root root  141 Nov  9  2019 .bash_profile
-rw-r--r--.   1 root root  312 Nov  9  2019 .bashrc
-rw-r--r--.   1 root root    0 Jul 13 00:07 null.test
-rw-r--r--.   1 root root    0 Jul 13 00:30 .Welcome
[00:30:54 root@C8[ ~]#useradd test985     ##新建用户test985
[00:31:17 root@C8[ ~]#ll -a /home/test985/ ##查看自动创建的家目录
total 12
drwx------. 2 test985 test985  95 Jul 13 00:31 .
drwxr-xr-x. 4 root    root     36 Jul 13 00:31 ..
-rw-r--r--. 1 test985 test985  18 Nov  9  2019 .bash_logout
-rw-r--r--. 1 test985 test985 141 Nov  9  2019 .bash_profile
-rw-r--r--. 1 test985 test985 312 Nov  9  2019 .bashrc
-rw-r--r--. 1 test985 test985   0 Jul 13 00:07 null.test
-rw-r--r--. 1 test985 test985   0 Jul 13 00:30 .Welcome  ##赫然在列
[00:31:39 root@C8[ ~]#ll -a /home/test211/  ##查看之前创建的test211用户家目录
total 12
drwxr-xr-x. 2 root root  79 Jul 13 00:16 .
drwxr-xr-x. 4 root root  36 Jul 13 00:31 ..
-rw-r--r--. 1 root root  18 Jul 13 00:16 .bash_logout
-rw-r--r--. 1 root root 141 Jul 13 00:16 .bash_profile
-rw-r--r--. 1 root root 312 Jul 13 00:16 .bashrc
-rw-r--r--. 1 root root   0 Jul 13 00:16 null.test  ##只有之前创建的文件,没有Welcome

推荐阅读