显示行号
|
选择喜欢的代码风格
默认
GitHub
Dune
LakeSide
Plateau
Vibrant
Blue
Eighties
Tranquil
last 命令显示最近登录用户的列表。
last 命令安装:
-bash: last command not found
#Debian
apt-get install util-linux
#Ubuntu
apt-get install util-linux
#Alpine
apk add util-linux
#Arch Linux
pacman -S util-linux
#Kali Linux
apt-get install util-linux
#CentOS
yum install sysvinit-tools
#Fedora
dnf install util-linux
#OS X
brew install util-linux
#Raspbian
apt-get install util-linux
#Docker
docker run cmd.cat/last last
last 命令补充说明:
last 命令搜索文件 /var/log/wtmp(或 -f 标志指定的文件),并显示自创建该文件以来所有已登录(和注销)的用户的列表。 可以指定用户和 tty 的名称,在这种情况下,last 仅显示与参数匹配的条目。 ttys 的名称可以缩写,因此 last 0 与 last tty0 相同。
last 命令语法:
last [-R] [-num] [ -n num ] [-adFiowx] [ -f file ] [ -t YYYYMMDDHHMMSS ] [
name...] [tty...]
last 命令选项:
-a:把从何处登入系统的主机名称或ip地址,显示在最后一行;
-d:将IP地址转换成主机名称;
-f :指定记录文件。
-n 或-:设置列出名单的显示列数;
-R:不显示登入系统的主机名称或IP地址;
-x:显示系统关机,重新开机,以及执行等级的改变等信息。
last 命令参数:
用户名:显示用户登录列表;
终端:显示从指定终端的登录列表。
last 命令实例
last 命令用了显示用户登录情况,以下是直接显示固定行数的记录:
[root@CommandNotFound ~]
$ last
root pts/0 61.49.113.210 Mon Oct 21 16:52 still logged in
root pts/2 61.49.113.210 Mon Oct 21 11:17 still logged in
root pts/1 61.49.113.210 Mon Oct 21 09:58 still logged in
root pts/0 61.49.113.210 Mon Oct 21 08:42 - 12:16 (03:33)
root pts/2 116.196.117.99 Fri Oct 18 10:30 - 15:29 (04:59)
root pts/1 116.196.117.99 Fri Oct 18 10:23 - 15:29 (05:05)
root pts/0 61.49.113.210 Fri Oct 18 08:19 - 18:36 (10:17)
root pts/1 61.49.113.210 Thu Oct 17 17:54 - 19:40 (01:46)
root pts/0 116.196.117.99 Thu Oct 17 17:15 - 18:38 (01:22)
root pts/0 116.196.117.99 Thu Oct 17 15:33 - 15:52 (00:19)
root pts/0 116.196.117.99 Wed Oct 16 11:08 - 21:39 (10:31)
root pts/1 116.196.117.99 Tue Oct 15 11:59 - 12:21 (00:21)
last 其他示例:
last reboot | less #查看最近重启记录
last -x | less #查看最近关机记录
last 命令扩展阅读:
last 命令评论