一些命令可以帮您了解Linux 操作系统用户信息
1 显示上次登录的用户信息列表,包括(登录时间、退出时间、登录IP):
[sywu@wusuyuan ~]$ last
root pts/1 192.168.1.3 Wed Aug 27 22:08 still logged in
sywu pts/0 192.168.1.3 Wed Aug 27 21:52 still logged in
reboot system boot 2.6.32-431.3.1.e Wed Aug 27 21:51 - 22:12 (00:21)
root pts/0 192.168.1.3 Mon Aug 25 23:03 - down (00:11)
root tty1 Mon Aug 25 22:48 - down (00:26)
reboot system boot 2.6.32-431.3.1.e Mon Aug 25 22:47 - 23:15 (00:27)
root tty1 Mon Aug 25 19:32 - down (00:00)
reboot system boot 2.6.32-431.3.1.e Mon Aug 25 19:23 - 19:32 (00:09)
root pts/2 192.168.1.3 Sun Aug 24 22:17 - 22:36 (00:18)
sywu pts/0 192.168.1.3 Sun Aug 24 22:13 - down (00:22)
2 显示上次用户登录信息(仅仅是上次),包括(登录时间、登录IP):
[root@wusuyuan ~]# lastlog --help
Usage: lastlog [options]
Options:
-b, --before DAYS print only lastlog records older than DAYS
-h, --help display this help message and exit
-t, --time DAYS print only lastlog records more recent than DAYS
-u, --user LOGIN print lastlog record of the specified LOGIN
[root@wusuyuan ~]# lastlog
用户名 端口 来自 最后登陆时间
root pts/2 192.168.1.3 日 8月 24 22:17:05 +0800 2014
gdm **从未登录过**
ntp **从未登录过**
saslauth **从未登录过**
postfix **从未登录过**
pulse **从未登录过**
sshd **从未登录过**
tcpdump **从未登录过**
vboxadd **从未登录过**
sywu pts/0 192.168.1.3 日 8月 24 22:13:52 +0800 2014
lanston pts/1 192.168.1.100 日 6月 8 17:08:10 +0800 2014
3.上次登录失败的用户信息:
[sywu@wusuyuan ~]$ sudo lastb
root ssh:notty 192.168.1.3 Wed Aug 27 22:16 - 22:16 (00:00)
root ssh:notty 192.168.1.3 Thu Aug 21 20:18 - 20:18 (00:00)
btmp begins Thu Aug 21 20:18:11 2014
4.谁登录了当前系统(包括IP、登录时间):
[root@wusuyuan ~]# who --help
用法:who [选项]... [ 文件 | 参数1 参数2 ]
显示当前已登录的用户信息。
-a, --all 等于-b -d --login -p -r -t -T -u 选项的组合
-b, --boot 上次系统启动时间
-d, --dead 显示已死的进程
-H, --heading 输出头部的标题列
-l,--login 显示系统登录进程
--lookup 尝试通过 DNS 查验主机名
-m 只面对和标准输入有直接交互的主机和用户
-p, --process 显示由 init 进程衍生的活动进程
-q, --count 列出所有已登录用户的登录名与用户数量
-r, --runlevel 显示当前的运行级别
-s, --short 只显示名称、线路和时间(默认)
-T, -w, --mesg 用+,- 或 ? 标注用户消息状态
-u, --users 列出已登录的用户
--message 等于-T
--writable 等于-T
--help 显示此帮助信息并退出
--version 显示版本信息并退出
[root@wusuyuan ~]# who -a
系统引导 2014-08-24 22:11
运行级别 3 2014-08-24 22:11
登录 tty1 2014-08-24 22:13 1996 id=1
登录 tty2 2014-08-24 22:13 1998 id=2
登录 tty3 2014-08-24 22:13 2000 id=3
登录 tty4 2014-08-24 22:13 2002 id=4
登录 tty5 2014-08-24 22:13 2008 id=5
登录 tty6 2014-08-24 22:13 2010 id=6
sywu + pts/0 2014-08-24 22:13 00:11 2011 (192.168.1.3)
root + pts/2 2014-08-24 22:17 . 2158 (192.168.1.3)
5.登录的用户当前在做什么:
[root@wusuyuan ~]# w --help
w:无效选项 -- -
usage: w -hlsufV [user]
-h skip header
-l long listing (default)
-s short listing
-u ignore uid of processes
-f toggle FROM field (default on)
-V display version
[root@wusuyuan ~]# w
22:28:03 up 16 min, 2 users, load average: 0.01, 0.02, 0.02
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
sywu pts/0 192.168.1.3 22:13 13:21 0.07s 0.01s rlwrap sqlplus / as sysdba
root pts/2 192.168.1.3 22:17 0.00s 0.13s 0.00s w
6.显示用户登录的时间:
[sywu@wusuyuan ~]$ ac #总的
total 115.46
[sywu@wusuyuan ~]$ ac -p
lanston 2.30
root 11.35
sywu 101.83
total 115.49
Hope is personal,hope is something that no one can give to you,you have to choose to believe in hope,you have to make it yourself..

浙公网安备 33010602011771号