码迷,mamicode.com
首页 > 系统相关 > 详细

记录Linux服务器命令行操作记录

时间:2019-04-03 18:08:42      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:linux   添加   sed -e   print   hostname   dir   history   awk   mkdir   

vim /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

记录Linux服务器命令行操作记录

标签:linux   添加   sed -e   print   hostname   dir   history   awk   mkdir   

原文地址:https://blog.51cto.com/13950323/2373794

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!