linux(centos 6)下记录所有用户的操作以及ip、时间
2017-01-09 07:34
711 查看
编辑/etc/profile文件,在文件末尾加入下面代码:
[root@iZ23nn1p4mjZ root]# vi /etc/profile
[root@iZ23nn1p4mjZ history]# ll
total 4
d-wx------ 2 root root 4096 Jan 9 07:29 root
[root@iZ23nn1p4mjZ root]# ll
total 4
-rw------- 1 root root 54 Jan 9 07:29 root@101.69.255.190_20170109_07:29:05
[root@iZ23nn1p4mjZ root]# vi /etc/profile
history USER=`whoami` USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'` if [ "$USER_IP" = "" ]; then USER_IP=`hostname` fi if [ ! -d /var/log/history ]; then mkdir /var/log/history chmod 777 /var/log/history fi if [ ! -d /var/log/history/${LOGNAME} ]; then mkdir /var/log/history/${LOGNAME} chmod 300 /var/log/history/${LOGNAME} fi export HISTSIZE=4096 DT=`date +"%Y%m%d_%H:%M:%S"` export HISTFILE="/var/log/history/${LOGNAME}/${USER}@${USER_IP}_$DT" chmod 600 /var/log/history/${LOGNAME}/*history* 2>/dev/null 注释: /var/log/history这是记录日志的存放位置,可以自定义。 在/var/log/history下会以每个用户为名新建一个文件夹
[root@iZ23nn1p4mjZ history]# ll
total 4
d-wx------ 2 root root 4096 Jan 9 07:29 root
[root@iZ23nn1p4mjZ root]# ll
total 4
-rw------- 1 root root 54 Jan 9 07:29 root@101.69.255.190_20170109_07:29:05
相关文章推荐
- linux 精确记录用户IP以及用户操作的两种方法
- 通过登入IP记录Linux所有用户登录所操作的日志
- 按时按登录IP记录Linux所有用户操作日志的方法
- Linux:history命令记录操作时间、操作用户、操作IP
- 按时按登录IP记录Linux所有用户操作日志的方法(附脚本)
- 通过登入IP记录Linux所有用户登录所操作的日志
- 通过登入IP记录Linux所有用户登录所操作的日志
- linux系统日志输出,记录用户登入信息以及登入ip,登入操作记录等
- 通过登陆IP记录Linux所有用户登录所操作的日志
- IP记录Linux所有用户操作日志的方法(附脚本)
- 按时按登录IP记录Linux所有用户操作日志
- 按时按登录IP记录Linux所有用户操作日志的方法(附脚本)
- 按登录IP记录Linux所有用户操作日志
- 通过登陆IP记录Linux所有用户登录所操作的日志
- 通过登陆IP记录Linux所有用户登录所操作的日志
- 按时按登录IP记录Linux所有用户操作日志的方法(附脚本)
- 通过登陆IP记录Linux所有用户登录所操作的日志
- 通过登陆IP记录Linux所有用户登录所操作日志的方法
- Linux下记录所有用户操作的脚本
- Linux下记录所有用户的操作命令,以方便后期审计