History displays the time information

简介: For those of you who use terminals a lot, one of the most common commands is probably history, which allows you to view the history of terminal commands executed

history 执行很简单:如下:参考

pi@raspberrypi:~ $ history

1  clear
2  ls
3  sudo apt update
4  df -h
5  sudo apt install vim
6  sudo reboot
7  clear
8  ls
9  sudo apt install vim

10 locale

Sometimes, however, we want to get more historical information, such as the time when a command was executed, to determine some actions.

针对 bash 这样设置

echo 'HISTTIMEFORMAT="%F %T "' >> ~/.bashrc
source ~/.bashrc

然后再次执行
history

1  2022-02-06 21:55:32 clear
2  2022-02-06 21:55:32 ls
3  2022-02-06 21:55:32 sudo apt update
4  2022-02-06 21:55:32 df -h
5  2022-02-06 21:55:32 sudo apt install vim
6  2022-02-06 21:55:32 sudo reboot
7  2022-02-06 21:55:32 clear
8  2022-02-06 21:55:32 ls
9  2022-02-06 21:55:32 sudo apt install vim

10 2022-02-06 21:55:32 locale

However, for terminals that use the ZSH environment (such as OHmyzsh), the above configuration does not take effect, and history-i is required

history -i

1  2020-07-05 16:48  mv ~/Downloads/aaaaa.zip ./
2  2020-07-05 16:48  unzip aaaaa.zip
3  2020-07-03 21:58  export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;
4  2020-07-03 21:58  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
5  2020-07-03 22:10  sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
6  2020-07-03 22:13  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"\n
7  2020-07-03 22:44  cd OneDrive





目录
相关文章
|
5月前
|
Oracle 关系型数据库 数据库
Active Data Guard Real-Time Cascade
12c 的 Cascaded Standby 数据库
51 7
有趣的 events_statements_current 表问题
有趣的 events_statements_current 表问题
156 0
We cannot activate inspection type for article master in transaction code MM41?
We cannot activate inspection type for article master in transaction code MM41?
We cannot activate inspection type for article master in transaction code MM41?
|
算法 前端开发 弹性计算
译《Time, Clocks, and the Ordering of Events in a Distributed System》
Motivation 《Time, Clocks, and the Ordering of Events in a Distributed System》大概是在分布式领域被引用的最多的一篇Paper了。
906 0
0227show all segment level statistics
[20180227]show all segment level statistics.txt https://orainternals.wordpress.com/2013/06/12/dude-where-is-my-redo/ REM Author : Ri...
1015 1
|
容器 安全 物联网
Speed Matters: How To Process Big Data Securely For Real-time Applications
Big Data processing has stepped up to provide organizations with new tools and technologies to improve business efficiency and competitive advantage.
1312 0
Speed Matters: How To Process Big Data Securely For Real-time Applications
|
安全
How to Defend Against a Database Hit Attack in 10 Minutes or Less
The Alibaba Cloud Security team has detected more and more database hit attacks recently.
1816 0