Linux介绍和发展历史:带有日期和时间的 Linux命令历史记录

关于Linux介绍和发展历史的问题,在history with timestamp中经常遇到, 我想检查我的 linux 系统,当哪个命令被解雇-在哪个日期和时间。

我想检查我的 linux 系统,当哪个命令被解雇-在哪个日期和时间。

我发射命令是这样的:

history 50 

它向我展示了最后 50 个命令的历史记录,但没有显示它被触发的日期和时间。

61

Regarding this link您可以通过执行以下命令使first solution provided by krzyk成为永久性的:

echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
source ~/.bash_profile
37

试试这个:

> HISTTIMEFORMAT="%d/%m/%y %T "
> history

当然,您可以根据自己的喜好调整格式。

24

如果您使用的是 zsh,则可以使用-E-i开关:

history -E

如果您执行man zshoptionsman zshbuiltins,您可以找到有关这些开关的更多信息以及与历史记录相关的其他信息:

Also when listing,
 -d     prints timestamps for each event
 -f     prints full time-date stamps in the US `MM/DD/YY hh:mm' format
 -E     prints full time-date stamps in the European `dd.mm.yyyy hh:mm' format
 -i     prints full time-date stamps in ISO8601 `yyyy-mm-dd hh:mm' format
 -t fmt prints time and date stamps in the given format; fmt is formatted with the strftime function with the zsh extensions  described  for  the  %D{string} prompt format in the section EXPANSION OF PROMPT SEQUENCES in zshmisc(1).  The resulting formatted string must be no more than 256 characters or will not be printed
 -D     prints elapsed times; may be combined with one of the options above
5

它取决于标准 bash 中的 shell(及其配置),只有命令存储没有日期和时间(检查.bash_history如果有任何时间戳)。

要让 bash 存储时间戳,您需要在HISTTIMEFORMAT之前执行命令,例如在.bashrc.bash_profile中。这将导致 bash 将时间戳存储在.bash_history中(请参阅以#开头的条目)。

本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处

(881)
禁止网页弹出广告:在网页上查找广告(ads on webpages)
上一篇
内容付费源码:Youtube和Vimeo付费/私人内容
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(61条)