Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3152612
  • 博文数量: 443
  • 博客积分: 11301
  • 博客等级: 上将
  • 技术积分: 5678
  • 用 户 组: 普通用户
  • 注册时间: 2004-10-08 12:30
个人简介

欢迎加入IT云增值在线QQ交流群:342584734

文章分类

全部博文(443)

文章存档

2022年(1)

2021年(1)

2015年(2)

2014年(1)

2013年(1)

2012年(4)

2011年(19)

2010年(32)

2009年(2)

2008年(4)

2007年(31)

2006年(301)

2005年(42)

2004年(2)

分类:

2006-09-11 10:47:48

转自:
 

BASH环境下:

SunLinux环境下

==============

用户的shell必须是/bin/bash
例如:

root:x:0:1:Super-User:/:/bin/bash

vi /etc/profile

添加如下内容:
# history
USER_IP=`who am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`

if [ "$USER_IP" = "" ]
then
  USER_IP=`hostname`
fi

if [ ! -d /tmp/.hist ]
then
   mkdir /tmp/.hist
   chmod 777 /tmp/.hist
fi

if [ ! -d /tmp/.hist/${LOGNAME} ]
then
    mkdir /tmp/.hist/${LOGNAME}
    chmod 300 /tmp/.hist/${LOGNAME}
fi
HISTSIZE=4096
export HISTSIZE
DT=`date "+%Y%m%d_%H%M%S"`
export DT
HISTFILE="/tmp/.hist/${LOGNAME}/${USER_IP}.hist.$DT"
export HISTFILE
chmod 600 /tmp/.hist/${LOGNAME}/*.hist* 2>/dev/null
umask 022

 

则在/tmp/.hist/下有记录

 

 

 

 

 

 

Ksh 环境下:

AIX 5.2

===============

 

PS1="`whoami`@`hostname`:"'[$PWD]'
# history
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 /tmp/.hist ]
then
   mkdir /tmp/.hist
   chmod 777 /tmp/.hist
fi

if [ ! -d /tmp/.hist/${LOGNAME} ]
then
    mkdir /tmp/.hist/${LOGNAME}
    chmod 300 /tmp/.hist/${LOGNAME}
fi

export HISTSIZE=4096
DT=`date "+%Y%m%d_%H%M%S"`
export HISTFILE="/tmp/.hist/${LOGNAME}/${USER_IP}.hist.$DT"
chmod 600 /tmp/.hist/${LOGNAME}/*.hist* 2>/dev/null


把这些东西加入到你的/etc/profile里面就好了。

这个东西在登录的时候会在你的/tmp/下面建立一个。hist的目录。每个用户使用什么ip地址和什么时间内连接上来的。都写在这个里面了。
这样比较方便查看别人干什么了。
到不是为了监视任何人。只是感觉这样管理比较方便。
感谢sakulagi的帮助:)

 

以上是在aix 52上面测试通过的。同样在hp上面也是能够使用的。只是不需要
|sed -e 's/[()]//g'


希望能够对有用的人有用。

阅读(4847) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~