linux查看用户相关信息的命令

1.查看用户信息的命令:id 参数 用户名

powershell 复制代码
参数
-g	显示用户所属群组的ID
-u	显示用户ID
-G	显示用户所属附加群组的ID

执行id命令不加用户名,默认输出当前用户的ID信息

查看linzef用户的信息:

powershell 复制代码
[root@master ~]# id linzef
uid=1000(linzef) gid=1000(oinstall) groups=1000(oinstall),1001(dba)

2.查看用户所在组的命令:groups 参数 用户名

查看linzef用户所在的组:

powershell 复制代码
[root@master ~]# groups linzef
linzef : oinstall dba

3.查看当前登录用户命令:whoami

powershell 复制代码
[root@master ~]# whoami
root
[root@master ~]# who am i
root     pts/0        2023-11-07 17:42 (192.168.16.1)

4.查看当前用户命令w

powershell 复制代码
[root@master ~]# w
 18:11:51 up 31 min,  1 user,  load average: 0.00, 0.01, 0.01
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0     17:42    7.00s  0.00s  0.00s w

5.查看登录用户命令:who

6.查看登录历史用户命令:last

powershell 复制代码
[root@master ~]# last
root     pts/0        192.168.16.1     Tue Nov  7 17:42   still logged in   
reboot   system boot  3.10.0-123.el7.x Tue Nov  7 17:40 - 18:14  (00:34)    
root     pts/0        192.168.16.1     Thu Oct 19 18:54 - crash (18+22:45)  
reboot   system boot  3.10.0-123.el7.x Thu Oct 19 18:54 - 18:14 (18+23:20)  
root     pts/0        192.168.16.1     Thu Oct 12 22:19 - crash (6+20:34)   
root     pts/0        192.168.16.1     Thu Oct 12 19:05 - 21:51  (02:46)    
reboot   system boot  3.10.0-123.el7.x Thu Oct 12 19:04 - 18:14 (25+23:10)  
root     pts/0        192.168.16.1     Mon Oct  9 23:12 - crash (2+19:52)   
reboot   system boot  3.10.0-123.el7.x Mon Oct  9 23:12 - 18:14 (28+19:02)  
root     pts/0        192.168.16.1     Sun Oct  8 21:50 - crash (1+01:21)   
reboot   system boot  3.10.0-123.el7.x Sun Oct  8 21:49 - 18:14 (29+20:25)  
root     pts/0        192.168.16.1     Thu Aug 31 16:45 - 16:46  (00:00)    
reboot   system boot  3.10.0-123.el7.x Thu Aug 31 16:45 - 18:14 (68+01:29)  
reboot   system boot  3.10.0-123.el7.x Thu Aug 31 16:45 - 16:45  (00:00)    
root     pts/0        192.168.16.1     Wed Aug 30 17:53 - crash  (22:51)    
root     tty1                          Wed Aug 30 17:52 - crash  (22:52)    
reboot   system boot  3.10.0-123.el7.x Wed Aug 30 17:52 - 16:45  (22:53)    
root     pts/0        192.168.16.1     Wed Aug 30 17:47 - down   (00:04)    
root     pts/0        192.168.16.1     Wed Aug 30 16:40 - 17:47  (01:06)    
reboot   system boot  3.10.0-123.el7.x Wed Aug 30 16:40 - 17:51  (01:11)    
root     pts/0        192.168.16.1     Mon Aug 28 21:52 - crash (1+18:48)   
reboot   system boot  3.10.0-123.el7.x Mon Aug 28 21:47 - 17:51 (1+20:03)   
root     pts/0        192.168.16.1     Mon Jul 24 21:01 - 00:28  (03:27)    
root     pts/2        192.168.16.1     Mon Jul 24 19:47 - 20:29  (00:42)    
root     pts/1        192.168.16.1     Mon Jul 24 19:21 - 19:47  (00:25)    
root     pts/1        192.168.16.1     Mon Jul 24 18:50 - 19:20  (00:30)    
root     pts/0        192.168.16.1     Mon Jul 24 17:05 - 20:59  (03:54)    
reboot   system boot  3.10.0-123.el7.x Mon Jul 24 17:04 - 17:51 (37+00:47)  
root     pts/0        192.168.16.1     Tue Jun 13 17:05 - crash (40+23:58)  
root     pts/0        192.168.16.1     Tue Jun 13 00:11 - 17:05  (16:53)    
root     pts/0        192.168.16.1     Tue Jun 13 00:11 - 00:11  (00:00)    
root     pts/1        192.168.16.1     Tue Jun 13 00:10 - 00:11  (00:01)    
root     pts/0        192.168.16.1     Tue Jun 13 00:00 - 00:10  (00:10)    
root     tty1                          Mon Jun 12 23:51 - crash (41+17:13)  
reboot   system boot  3.10.0-123.el7.x Mon Jun 12 23:47 - 17:51 (78+18:04)  

wtmp begins Mon Jun 12 23:47:41 2023
相关推荐
想学习java初学者16 分钟前
Docker compose部署elasticsearch(单机版)
运维·docker·容器
人类群星闪耀时43 分钟前
未来运维的发展趋势:运维领域的新技术与趋势
运维
落非1 小时前
NFS存储基础操作
运维
Vanish_ran1 小时前
gitlab与jenkins
运维·gitlab·jenkins
朱容君1 小时前
Linux系统编程多线程之读写锁讲解
linux·开发语言
大风吹PP凉1 小时前
38配置管理工具(如Ansible、Puppet、Chef)
linux·运维·服务器·ansible·puppet
康熙38bdc2 小时前
Linux 进程间通信——共享内存
linux·运维·服务器
jwybobo20072 小时前
redis7.x源码分析:(3) dict字典
linux·redis
scoone2 小时前
ssh登陆服务器后支持Tab键命令补全
linux·shell
微刻时光2 小时前
Docker部署Nginx
运维·nginx·docker·容器·经验