一
为历史的命令增加登录的IP地址、执行命令时间等信息:
1、保存1万条命令
sed -i 's/^HISTSIZE=1000/HISTSIZE=10000/g' /etc/profile
2、在/etc/profile的文件尾部添加如下行数配置信息:
######jiagu history xianshi#########
USER_IP=`who -u am i 2>/dev/null | awk '{print $NF}' | sed -e 's/[()]//g'`
if [ "$USER_IP" = "" ]
then
USER_IP=`hostname`
fi
export HISTTIMEFORMAT="%F %T $USER_IP `whoami` "
shopt -s histappend
export PROMPT_COMMAND="history -a"
######### jiagu history xianshi ##########
3、source /etc/profile让配置生效
历史操作命令的清除:history -c
但此命令并不会清除保存在文件中的记录,因此需要手动删除.bash_profile文件中的记录。
二
1、查询特权用户特权用户(uid 为0)
[root@localhost ~]# awk -F: '
1}' /etc/passwd
2、查询可以远程登录的帐号信息
[root@localhost ~]# awk '/$1|$6/{print
" | grep "ALL=(ALL)"
4、禁用或删除多余及可疑的帐号
usermod -L user 禁用帐号,帐号无法登录,/etc/shadow第二栏为!开头
userdel user 删除user用户
userdel -r user 将删除user用户,并且将/home目录下的user目录一并删除