The last command can be used to view User Login records.
The history command can view the command execution history. Common log files www.2cto.com are as follows: access-log record HTTP/web transmission acct/pacct record USER command aculog record MODEM activity btmp record failure record lastlog record recent successful login events and last unsuccessful log on to messages to record information from syslog (some links to the syslog file) sudolog records the use of sudo commands sulog records the use of syslogs using the su command to record information from syslogs (usually linked to the messages file) utmp records the number of currently logged-on users. Each user wtmp records the number of permanent records for each login Entry and Exit Time. xferlog records the FTP session ~ /. Bash_history contains no time records. You can use the following script to record the time.
You can add the following code to/etc/profile: PS1 = "'whoam' @ 'hostname ': "'[$ PWD] 'History www.2cto.com USER_IP = 'Who-u am I 2>/dev/null | awk' {print $ NF} '| sed-e's /[ ()] // g'' # print $ NF obtain the field of the last domain if ["$ USER_IP" = ""] then USER_IP = 'hostname' fi if [! -D/tmp/dbasky] then mkdir/tmp/dbasky chmod 777/tmp/dbasky fi if [! -D/tmp/dbasky/$ {LOGNAME}] then mkdir/tmp/dbasky/$ {LOGNAME} chmod 300/tmp/dbasky/$ {LOGNAME} fi export HISTSIZE = 4096 DT = 'date "% Y % m % d _ % H % M % S" 'export HISTFILE = "/tmp/dbasky/$ {LOGNAME}/$ {USER_IP} dbasky. $ DT "chmod 600/tmp/dbasky/$ {LOGNAME}/* dbasky * 2>/dev/null
In fact, the above Code cannot tell you that it is very convenient to create a dbasky directory in/tmp of the system and record all users and IP addresses that have logged on to the system in the directory? We can also use this method to monitor system security. Www.2cto.com, you can see that there is no time to display the history command, and you do not know when the command is executed. At this time, you can edit the/etc/bashrc file and add the following three lines: HISTFILESIZE = 2000 HISTSIZE = 2000 HISTTIMEFORMAT = "% Y % m % d-% H % M % S:" export HISTTIMEFORMAT
Save and exit. Close the current shell and log on again ~ /. In the bash_History file, the command execution time is recorded by the author huaius.