一、查看用户信息
1. id 查看UID、GID等信息
用法:
id 用户
[root@oldboy ~]# id oldboy
uid=1000(oldboy) gid=1000(oldboy) 组=1000(oldboy),10(wheel)
方法2:添加一个用户属于wheel组,用户即为管理员
[root@oldboy ~]# useradd test7 -g wheel
[root@oldboy ~]# id test7
uid=6669(test7) gid=10(wheel) 组=10(wheel)
test7即为管理员
[root@oldboy ~]# echo 123456|passwd --stdin test7
更改用户 test7 的密码 。
[root@oldboy ~]# su - test7
[test7@oldboy ~]$ sudo su - root
[sudo] test7 的密码:
[root@oldboy ~]#
2. whoami 查看当前用户
[root@oldboy ~]# whoami
root
3. who (了解)查看登录情况
4. w 与who用法相同,但是比较详细
[root@oldboy ~]# w
23:32:42 up 5 days, 21:09, 2 users, load average: 2.36, 2.49, 2.39
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 10.0.0.1 267月21 ? 1.08s 0.56s -bash
root pts/1 10.0.0.1 02:44 2.00s 0.22s 0.05s w