练习1:手动创建用户test

一、目的

了解用户创建过程


二、操作过程

1、新建一个没有家目录的用户test

[root@localhost ~]# useradd -M test


2、将目录/etc/skel复制创建家目录/home/test

[root@localhost ~]# cp -r /etc/skel /home/test


3、/home/test目录被创建后,其属主及属组都为root

[root@localhost home]# ls -dl /home/test
drwxr-xr-x 3 root root 4096 Oct 17 14:15 /home/test
[root@localhost home]# ls -al /home/test/
total 56
drwxr-xr-x 3 root root 4096 Oct 17 14:15 .
drwxr-xr-x 6 root root 4096 Oct 17 14:15 ..
-rw-r--r-- 1 root root   33 Oct 17 14:15 .bash_logout
-rw-r--r-- 1 root root  176 Oct 17 14:15 .bash_profile
-rw-r--r-- 1 root root  124 Oct 17 14:15 .bashrc
-rw-r--r-- 1 root root  515 Oct 17 14:15 .emacs
drwxr-xr-x 4 root root 4096 Oct 17 14:15 .mozilla


4、将test用户的家目录属主及属组改为用户本身test

[root@localhost home]# chown -R test.test test /home/test/


5、再次查看test用户家目录从属属性

[root@localhost home]# ls -dl /home/test
drwxr-xr-x 3 test test 4096 Oct 17 14:15 /home/test
[root@localhost home]# ls -al /home/test/
total 56
drwxr-xr-x 3 test test 4096 Oct 17 14:15 .
drwxr-xr-x 6 root      root      4096 Oct 17 14:15 ..
-rw-r--r-- 1 test test   33 Oct 17 14:15 .bash_logout
-rw-r--r-- 1 test test  176 Oct 17 14:15 .bash_profile
-rw-r--r-- 1 test test  124 Oct 17 14:15 .bashrc
-rw-r--r-- 1 test test  515 Oct 17 14:15 .emacs
drwxr-xr-x 4 test test 4096 Oct 17 14:15 .mozilla


6、将test用户属组及其他用户对家目录的访问权限改为没有任何权限

[root@localhost home]# chmod -R go= /home/test/


7、同第5步操作

[root@localhost home]# ls -al /home/test/
total 56
drwx------ 3 test test 4096 Oct 17 14:15 .
drwxr-xr-x 6 root      root      4096 Oct 17 14:15 ..
-rw------- 1 test test   33 Oct 17 14:15 .bash_logout
-rw------- 1 test test  176 Oct 17 14:15 .bash_profile
-rw------- 1 test test  124 Oct 17 14:15 .bashrc
-rw------- 1 test test  515 Oct 17 14:15 .emacs
drwx------ 4 test test 4096 Oct 17 14:15 .mozilla
[root@localhost home]# ls -dl /home/test
drwx------ 3 test test 4096 Oct 17 14:15 /home/test


你可能感兴趣的:(用户,新建)