通过登入IP记录Linux所有用户登录所操作的日志
来源:互联网 发布:谷歌去马赛克软件 编辑:程序博客网 时间:2024/06/05 06:23
对于Linux用户操作记录一般通过命令history来查看历史记录,但是如果在由于误操作而删除了重要的数据的情况下,history命令就不会有什么作用了。那么依然要存有历史操作记录应该如何来实现呢?其实我们可以通过登陆IP地址来记录所有用户登录所操作的历史操作!
具体操作就是在/etc/profile.d/里添加配置文件的末尾加入以下脚本代码来实现:
#sudo vi /etc/profile.d/user_all_history.sh
粘贴:
# HistoryUSER=`whoami`USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`if [ "$USER_IP" = "" ]; thenUSER_IP=`hostname`fiif [ ! -d /usr/local/history ]; thenmkdir /usr/local/historychmod 777 /usr/local/historyfiif [ ! -d /usr/local/history/${LOGNAME} ]; thenmkdir /usr/local/history/${LOGNAME}chmod 300 /usr/local/history/${LOGNAME}fiexport HISTSIZE=10000DT=`date +"%Y-%m-%d_%H:%M:%S"`export HISTFILE="/usr/local/history/${LOGNAME}/${USER}@${USER_IP}_history.$DT"chmod 600 /usr/local/history/${LOGNAME}/*history* 2>/dev/null
[root@server ~]# source /etc/profile.d/user_all_history.sh
[root@server ~]# logout
此时需要退出系统再重新登录,在/usr/local/history/目录下才有记录
[root@server ~]# ll /usr/local/history/root/总用量 12-rw------- 1 root root 77 10月 11 09:09 root@192.168.1.23_history.2012-10-11_09:09:12-rw------- 1 root root 529 10月 11 09:11 root@192.168.1.23_history.2012-10-11_09:09:16-rw------- 1 root root 187 10月 11 09:12 root@192.168.1.23_history.2012-10-11_09:11:26
如果想只有root可见可以:
#sudo chmod 400 /etc/profile.d/user_all_history.sh
0 0
- 通过登入IP记录Linux所有用户登录所操作的日志
- 按登录IP记录Linux所有用户操作日志
- Linux 记录所有用户登录和操作的详细日志
- 查看某个用户的登入邮箱的记录
- linux 实现通过记录登陆后的IP地址和某用户名所操作的历史记录
- Linux 查看登录日志及登录失败用户的ip
- springAop之 记录登入日志
- 记录每个用户的 登入 和 记录他们的命令 (sudo 也适用)
- linux history 记录 时间 ip 登录用户
- linux下查看所有登录用户的历史操作命令
- 登入oracle程序的ip address
- Linux中系统户登录和操作日志的记录
- Linux下记录所有用户操作的脚本
- Linux下记录所有用户操作的脚本
- linux记录用户操作命令日志
- Linux下记录用户操作日志
- Linux精确记录 用户ip及操作
- 01---实例操作(用户登入系统)
- R语言包_plyr
- 计算机科学与技术反思录
- jQuery的append方法的一些问题
- Codeforces 573 A. Bear and Poker
- JVM自动内存管理
- 通过登入IP记录Linux所有用户登录所操作的日志
- Qt网络编程—TCP/IP(一)
- Tomcat学习之ClassLoader
- DB2修改表深度分析
- 不可变字典NSDictionary 和可可变字典NSMutableDictionary
- #import与@class的区别
- 完成端口GetQueuedCompletionStatus()返回错误,怎样获得真正的错误代码
- Vim配置 显示行号 语法高亮 智能缩进 更适合程序员使用
- SPOJ 375 树链剖分学习