Linux system can use the history command to view the history of instructions. In order to improve the efficiency of the history command, you can also add some parameters to the history command, such as time, user and IP parameters. So how do you add these parameters to the history?
1. set the display time and the user:
echo & lsquo; export HISTTIMEFORMAT = & ldquo;% F% T `whoami` & rdquo; & rsquo;" "/etc /profile
Execute source to take effect:
source /etc/profile
View results:
history
1852 2016-01-11 16:24 :52 xubo hs
1853 2016-01-11 16:24:53 xubo ls
1854 2016-01-11 16:24:56 xubo history
1855 2016 -01-11 16:25:02 xubo history --help
1856 2016-01-11 16:26:35 xubo vi /etc/profile
1857 2016-01-11 16 :27:27 xubo echo ‘export HISTTIMEFORMAT=“%F %T `whoami` ”’ 》 /etc/profile
1858 2016-01-11 16:27:29 xubo vi /Etc/profile
1859 2016-01-11 16:27:42 xubo source /etc/profile
1860 2016-01-11 16:27:46 xubo history
1861 2016-01-11 16:27:59 xubo ls
1862 2016-01-11 16:28:01 xubo history
1863 2016-01-11 16:31:00 Xubo clear
1864 2016-01-11 16:31:02 xubo history
2. Only see your own operation record (time, user, ip name):
USER_IP=`who -u am i 2》/dev/null|
Awk ‘{print $NF}’|
Sed -e ‘s/[()]//g’`
xport HISTTIMEFORMAT=“[%F %T][`whoami`][${USER_IP}] ”
Execute source to take effect:
source /etc/profile
View results:
hadoop@Master:~$ history
1002 [2016-01 -11 16:47:37][hadoop][host-e-150.ustcsz.edu.cn] cd . . /
1003 [2016-01-11 16:47:37][hadoop][host-e-150.ustcsz.edu.cn] du -h --max-depth=1
1004 [2016-01-11 16:47:37][hadoop][host-e-150.ustcsz.edu.cn] du -h --max-depth=2
1005 [2016 -01-11 16:47:37][hadoop][host-e-150.ustcsz.edu.cn] sudo find /* -name pokec-relationships
1006 [2016-01-11 16: 47:37][hadoop][host-e-150.ustcsz.edu.cn] sudo find /* -name pokec
1007 [2016-01-11 16:47:37][hadoop][ Host-e-150.ustcsz.edu.cn] sudo find /* -name kddcup
1008 [2016-01-11 16:47:37][hadoop][host-e-150.ustcsz. Edu.cn] sudo find /* -name kddcup*
1009 [2016-01-11 16:47:37][hadoop][host-e-150.ustcsz.edu.cn] sudo find /* -name *kddcup*
3. Record the history to the log:
#export HISTTIMEFORMAT=“%F %T $USER_IP:`whoami` ”
#export HISTTIMEFORMAT=“%F %T $USER_IP:`whoami` ”
USE R_IP=`who -u am i 2》/dev/null|
Awk ‘{print $NF}’|
Sed -e ‘s/[()]//g’`
export HISTTIMEFORMAT=“[%F %T][`whoami`][${USER_IP}] ”
#history
LOGIP=`who -u am i 2》/dev/null|
Awk ‘{print $NF}’|
Sed -e ‘s/[()]//g’`
LOG_DIR=/var/log/history
if [ -z $LOGIP ]
then
LOGIP=`hostname`
fi
if [ ! -d $LOG_DIR ]
then
mkdir -p $LOG_DIR
chmod 777 $LOG_DIR
fi
if [ ! -d $LOG_DIR/${LOGNAME} ]
then
mkdir -p $LOG_DIR/${LOGNAME}
chmod 777 $LOG_DIR/${LOGNAME}
fi
export HISTSIZE=4096
LOGTM=`date +“%Y%m%d_%H%M%S”`
export HISTFILE =“$LOG_DIR/${LOGNAME}/${LOGIP}-$LOGTM”
chmod 777 $LOG_DIR/${LOGNAME}/*-* 2》/dev/null
Run results:
root@xubo:/media/xubo/My Passport/gene_data/1000genomes# ls /var/log/history/root/
host-e-150.ustcsz.edu .cn-20160111_171845 host-e-150.ustcsz.edu.cn-20160111_172719 host-e-213.ustcsz.edu.cn-20160111_202047
root@xubo:/media/xubo/My Passport/gene_data/1000genomes# vi /var/log/history/root/host-e-213.ustcsz.edu.cn-20160111_202047
#1452514808
ls root/
#1452514818
history
#1452514847
source /etc/profile
#1452514848
history
#1452514860< Br>
Ls root/
#1452514861
ls
#1452514863
cd root/
#1452514864
ls
#1452514866
exit
The above is how Linux adds time and user parameters to the history, so that the history can be displayed when viewing the command. And the user's these parameters, the search is more accurate.
Scrot is a screenshot tool used in the Linux command line, can perform full screen, select and other
In Linux system operation, sometimes you need to check the usage of cpu, which requires the use of L
In the Linux system, to set the boot, it is necessary to implement it through code.
Linux command reconfig can be used to convert configuration files, mainly used in XF86Config. The us
Linux system Vim how to install YouCompleteMe plug-in
Linux system using additional permissions method
Linux using the mpstat command method
Does Linux use the ODBC method or the DBI way to install the R language extension package?
Linux detection and prevention of DDOS attacks skills
What is the Linux system architecture?
Red Flag Linux6 installed Vmware Tools skills
How to modify the app icon icon under Ubuntu Gnome
After the Linux boot, the terminal prompts -bash-2.05b$ What should I do?
How to solve the garbled problem when opening Emacs under Linux?
Microsoft said that Win10 hides black and white icon design is not easy
How to remove the letters in the lower right corner of the win10 desktop?
What if the laptop camera can't be opened?
Bringing the Win8 system back to life Recovering, reinstalling and restoring the
New features of Win 7: Console Host (ConHost.exe)
What should I do if the winXP host has no sound in the front of the headset?
C disk is getting smaller and smaller how to do Win8.1 clean C disk slimming tutorial