Because Linux's default history record only saves the command content, there is no specific time, I can only find the user's logon and exit time to give them a time range.
Therefore, it is necessary to optimize the record function of history commands. The recommended parameters are as follows:
Edit/etc/profile and add the following configuration information:
|
# Set the file size for saving History commands |
|
Export HISTFILESIZE = 1000000000 |
|
# Number of historical commands saved |
|
Export HISTSIZE = 1000000 |
|
# Real-Time History commands. By default, records are recorded only after the user exits, which easily overwrites multiple users. |
|
Export PROMPT_COMMAND = "history-" |
|
# Record the execution time of each historical command |
|
Export HISTTIMEFORMAT = "% Y-% m-% d _ % H: % M: % S" Or: export HISTTIMEFORMAT = "% F % T 'whoam '" |
|
|
|
|
|
|
|
|
|
Make changes take effect immediately:
# Source/etc/bashrc