Ps:linux user operations records are generally viewed through the command history, but if the important data is deleted because someone mistakenly manipulated it, this situation does not work. The following methods can be implemented by logging the login IP address and all users log on the operation of logging!
The following script code can be implemented at the end of the/etc/profile configuration file , as can be seen from the above code, in the system's/tmp New History directory (this directory can be customized), All the users and IP addresses of the logged-in system are recorded in the directory, which is one of the methods to monitor the system security.
ps1="' whoami ' @ ' hostname ':"'[$PWD]'historyuser_ip=`W.H.O.-U am I2>/dev/NULL|awk '{print $NF}'|sed-E's/[()]//g'`if["$USER _ip"="" ] Thenuser_ip=`hostname`fiif[!-d/tmp/History ] Thenmkdir/tmp/ Historychmod 777/tmp/ Historyfiif[!-d/tmp/history/${logname}] Thenmkdir/tmp/history/${logname}chmod -/tmp/history/${logname}fiExport Histsize=4096DT=`Date+"%y%m%d_%h%m%s"' Export Histfile="/tmp/history/${logname}/${user_ip} history. $DT"chmod -/tmp/history/${logname}/*history* 2>/dev/null through the above code can be seen in the system/TMP to create a new history directory (this directory can be customized), in the directory to record all the users and IP addresses logged in the system, which is one of the methods to monitor the system security.
Linux Logging Logon IP method