[root@localhost ~]# su - test su: user test does not exist [root@localhost ~]# vim /etc/passwd test:x:1001:1001:test:/home/test:/bin/bash [root@localhost ~]# su - test Last login: Mon Feb 8 20:29:52 CST 2016 on :0 su: warning: cannot change directory to /home/test: No such file or directory id: cannot find name for group ID 1001 mkdir: cannot create directory '/home/test': Permission denied -bash-4.2$ echo$USER test -bash-4.2$ logout [root@localhost ~]# mkdir /home/test [root@localhost ~]# cd /home [root@localhost home]# ll total 4 drwx------. 14 student student 4096 Feb 2 12:23 student drwxr-xr-x. 2 root root 6 Feb 9 00:46 test [root@localhost home]# chown test.test test/ chown: invalid user: ‘test.test’ [root@localhost home]# groupadd -g 1001 test [root@localhost home]# chown test.test test/ [root@localhost home]# chmod go-rx test/ [root@localhost home]# ll total 4 drwx------. 14 student student 4096 Feb 2 12:23 student drwx------. 2 testtest 6 Feb 9 00:46 test [root@localhost home]# su - test Last login: Tue Feb 9 00:45:43 CST 2016 on pts/0 -bash-4.2$ cp /etc/skel/.* . cp: omitting directory ‘/etc/skel/.’ cp: omitting directory ‘/etc/skel/..’ cp: omitting directory ‘/etc/skel/.mozilla’ -bash-4.2$ logout [root@localhost home]# su - test Last login: Tue Feb 9 00:52:36 CST 2016 on pts/0 [test@localhost ~]$
id 用户名 ##查看用户信息 id -u 用户名 ##用户uid id -g 用户名 ##用户gid id -a 用户名 ##用户所有信息 id -G 用户名 ##用户所在所有的id id -un 用户名 ##用户名字 id -gn 用户名 ##用户初始组名称 id -Gn 用户名 ##用户所在所有组名称