Linux history时间用户ip设置
2016-06-24 12:01
344 查看
Linux history时间用户ip设置
在使用linux服务器的时候发生一些不知道谁操作的问题,google一下说history命令可以查看到历史记录,用过之后发现还是不够详细,再google,原来可以自己设置history的显示。
1.用vi编辑器打开/etc/profile
2.最后加两句代码
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
export HISTTIMEFORMAT="[%F %T][`whoami`][${USER_IP}] "
3.source /etc/profile
4.执行history
显示如下:
1000 [2012-09-08 04:05:09][root][192.168.10.136] history
1001 [2012-09-08 04:14:24][root][192.168.10.136] cd root
1002 [2012-09-08 04:14:27][root][192.168.10.136] ls
1003 [2012-09-08 04:14:30][root][192.168.10.136] cd /opt
在使用linux服务器的时候发生一些不知道谁操作的问题,google一下说history命令可以查看到历史记录,用过之后发现还是不够详细,再google,原来可以自己设置history的显示。
1.用vi编辑器打开/etc/profile
2.最后加两句代码
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
export HISTTIMEFORMAT="[%F %T][`whoami`][${USER_IP}] "
3.source /etc/profile
4.执行history
显示如下:
1000 [2012-09-08 04:05:09][root][192.168.10.136] history
1001 [2012-09-08 04:14:24][root][192.168.10.136] cd root
1002 [2012-09-08 04:14:27][root][192.168.10.136] ls
1003 [2012-09-08 04:14:30][root][192.168.10.136] cd /opt
相关文章推荐
- linux centos7 环境变量设置
- linux下mysql数据库基础及客户端命令详解
- linux下查看进城(ps)的方法 与 杀死进程(kill)的N种方法
- 第八章:Linux磁盘与文件系统管理
- linux下一些sh命令用法记录
- centos6.5(腾讯云)安装xampp
- linux 批量查找匹配文件 (批量修改内容)
- CentOS 7运维管理笔记(2)----修改命令提示符颜色
- [LINUX] selinux(androidboot.selinux) 的不同模式
- centos 创建本地yum源搭建本地yum仓库 亲测可用
- Linux软件安装管理(四)-源码安装
- Cobbler6.4 linux系统自动化安装脚本
- linux/eclipse/c++ 动态库的创立与调用
- Linux中搭建常用服务器
- linux下查看和添加path环境变量
- 下一代独立式 GNU/Linux 应用打包格式 Flatpak 发布
- Linux下screen命令的使用
- linux在个人目录下安装python
- sftp登录linux Received message too long (or "Bad packet length") 原因,已解决
- linux服务器git pull/push时提示输入账号密码之免除设置