lastcomm 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

lastcomm 命令安装:


-bash/zsh: lastcomm command not found

#Debian
apt-get install acct

#Ubuntu
apt-get install acct

#Alpine
apk add acct

#Kali Linux
apt-get install acct

#CentOS
yum install psacct

#Fedora
dnf install psacct

#Raspbian
apt-get install acct

#Docker
docker run cmd.cat/lastcomm lastcomm

lastcomm 命令语法:


lastcomm [ -X ][ Command ] [ Name ] [ Terminal ]

lastcomm 命令选项:


S	超级用户执行了该命令。
F	该命令在执行分叉之后运行,但没有以下子例程。
C	该命令在PDP-11兼容模式下运行。
d	该命令以生成核心文件终止。
X	该命令以信号终止。

------------------------------------------------------------

-strict-match:精确匹配每一列
--user name:只显示指定用户的命令记录。
--command name:只显示指定命令的记录。
--tty name:只显示在指定终端上运行的命令。
-f filename:指定一个命令记录文件来代替默认文件——acct。
--debug:打印其他内核信息。
-V,--version:打印版本。
-h,--help:打印概要和系统默认统计文件(Linux里面的默认文件多是/var/log/pacct 和/var/account/pacct)。

lastcomm 命令实例:


[root@redis-01 /home/yongyu]
$ lastcomm ls

ls                     root     pts/1      0.00 secs Tue Mar 26 11:57
ls                     root     pts/1      0.00 secs Tue Mar 26 11:56
ls                     root     pts/1      0.00 secs Tue Mar 26 11:56
ls                     root     pts/1      0.00 secs Tue Mar 26 11:55
ls                     root     pts/1      0.00 secs Tue Mar 26 11:55
ls                     root     pts/1      0.00 secs Tue Mar 26 11:54
ls                     root     pts/1      0.00 secs Tue Mar 26 11:53
ls                     root     pts/1      0.00 secs Tue Mar 26 11:53
ls                     root     pts/1      0.00 secs Tue Mar 26 11:53
ls                     root     pts/1      0.00 secs Tue Mar 26 11:51
ls                     root     pts/1      0.00 secs Tue Mar 26 11:51
ls                     root     pts/1      0.00 secs Tue Mar 26 11:51
ls                     root     pts/1      0.00 secs Tue Mar 26 11:49

# lastcomm yongyu
sa                     yongyu   pts/2      0.00 secs Tue Mar 26 11:59
bash              F    yongyu   pts/2      0.00 secs Tue Mar 26 11:59
id                     yongyu   pts/2      0.00 secs Tue Mar 26 11:59
bash              F    yongyu   pts/2      0.00 secs Tue Mar 26 11:59
consoletype            yongyu   pts/2      0.00 secs Tue Mar 26 11:59
grep                   yongyu   pts/2      0.00 secs Tue Mar 26 11:59
bash              F    yongyu   pts/2      0.00 secs Tue Mar 26 11:59
dircolors              yongyu   pts/2      0.00 secs Tue Mar 26 11:59
bash              F    yongyu   pts/2      0.00 secs Tue Mar 26 11:59
tput                   yongyu   pts/2      0.00 secs Tue Mar 26 11:59
tty                    yongyu   pts/2      0.00 secs Tue Mar 26 11:59
grepconf.sh            yongyu   pts/2      0.00 secs Tue Mar 26 11:59

# lastcomm | grep "Mar 26 12:0[2]"  
UpgradePlugin    S   X root     __         0.00 secs Tue Mar 26 12:02
MonitorPlugin    S   X root     __         0.00 secs Tue Mar 26 12:02
getconf                root     __         0.00 secs Tue Mar 26 12:02
getconf                root     __         0.00 secs Tue Mar 26 12:02
bash             S     root     __         0.00 secs Tue Mar 26 12:02
bash              F    root     __         0.00 secs Tue Mar 26 12:02
bash              F    root     __         0.00 secs Tue Mar 26 12:02
dirname                root     __         0.00 secs Tue Mar 26 12:02
sh                     root     __         0.00 secs Tue Mar 26 12:02
awk                    root     __         0.00 secs Tue Mar 26 12:02
grep                   root     __         0.00 secs Tue Mar 26 12:02
sh                     root     __         0.00 secs Tue Mar 26 12:02
awk                    root     __         0.00 secs Tue Mar 26 12:02
grep                   root     __         0.00 secs Tue Mar 26 12:02
cat                    root     __         0.00 secs Tue Mar 26 12:02
cat                    root     __         0.00 secs Tue Mar 26 12:02

lastcomm 命令扩展阅读:




lastcomm 命令评论

共收录到 507Linux 命令