1.用户增加删除
[root@VM_0_13_centos ~]# useradd better407 #添加 better407 用户
[root@VM_0_13_centos ~]# passwd better407 #设置 better407 密码
Changing password for user better407.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@VM_0_13_centos ~]# cat /etc/passwd # 查看本机所有用户
#用户名:口令(passwd):用户标识号(UID):组标识号(GID):注释性描述(users):主目录(home_directory):登录shell
better407:x:501:502::/home/better407:/bin/bash
[root@VM_0_13_centos ~]# userdel 123 #删除用户123
[root@VM_0_13_centos ~]# ls -l /home #不带选项使用 userdel,只会删除用户。用户的家目录将仍会在/home目录下
total 12
drwx------ 2 502 503 4096 Aug 10 10:06 123
drwx------ 2 better407 better407 4096 Aug 10 09:47 better407
drwx------ 3 centos centos 4096 Aug 1 10:10 centos
[root@VM_0_13_centos ~]# rm -rf /home/123 #删除用户123的家目录
[root@VM_0_13_centos ~]# ls /home
better407 centos
注:删除用户时完全删除家目录,使用 -r 选项 userdel -r 123
userdel 提供 -f 选项来强制删除用户。当用户已经登入 Linux 系统时此选项仍旧生效
2.查看用户创建日期
[root@VM_0_13_centos ~]# ls -l /home/better407/.bash_logout
-rw-r--r-- 1 better407 better407 18 Mar 23 2017 /home/better407/.bash_logout
3.登录用户
[root@VM_0_13_centos ~]# w
#查看登录用户正在使用的进程信息
10:23:34 up 9 days, 13 min, 2 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 XXX.XXX.242.227 09:15 1:08m 0.00s 0.00s -bash
root pts/1 XXX.XXX.242.227 09:42 0.00s 0.03s 0.00s w
[root@VM_0_13_centos ~]# who
#查看(登录)用户名称及所启动的进程
root pts/0 2018-08-10 09:15 (49.77.242.227)
root pts/1 2018-08-10 09:42 (49.77.242.227)
[root@VM_0_13_centos ~]# users
#打印输出登录服务器的用户名称
root root
[root@VM_0_13_centos ~]# whoami
#当前登入的用户名称
root
[root@VM_0_13_centos ~]# id -un
#当前登入的用户名称
root
[root@VM_0_13_centos ~]# last root
用户名称 tty设备号 ip地址: 历史登录时间日期:登出时间日期:总工作时间
root pts/1 XXX.XXX.242.227 Fri Aug 10 09:42 still logged in
root pts/0 XXX.XXX.242.227 Fri Aug 10 09:15 still logged in