This article is a mirror article of machine translation, please click here to jump to the original article.

View: 19212|Reply: 0

[linux] The Linux history command shows the time and the executing user

[Copy link]
Posted on 7/22/2021 9:29:34 AM | | | |
On Linux, we can view the history commands executed through the history command, which only displays the line number and the executed commands, but the only drawback is that it cannot display the execution time, as well as the IP address of the login, the execution user, and other information.

As shown below:



solution

Use the HISTTIMEFORMAT variable to specify that the timestamp is added to the command

edit/etc/profilefile, add the following variables at the bottom

After the modification is complete, restart the server, or refresh the profile with the following command:

Re-execute history as shown below:



remark

HISTTIMEFORMAT uses the time format of the strftime function.

Manual for strftime functions:

The hyperlink login is visible.

%F     Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99)
%T     The time in 24-hour notation (%H:%M:%S).  (SU)
(End)





Previous:Docker builds SFTP services
Next:The connection and difference between the Maven commands package, install, and deploy
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com