因为之前执行过:echo 'export HISTTIMEFORMAT="%F %T `whoami` "' > /etc/profile
谁知到 导致/etc/profile中的文件内容全没了,只剩下导入的这条:
export HISTTIMEFORMAT="%F %T `whoami` "
记录如下:
[root@lvs2 ~]# history >1.txt
[root@lvs2 ~]# ll
-bash: ll: command not found
[root@lvs2 ~]# ls
1.txt install.log keepalived-1.2.2 network-conf
anaconda-ks.cfg install.log.syslog keepalived-1.2.2.tar.gz
[root@lvs2 ~]# vi /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT good idea to change this file unless you know what you
# are doing. Much better way is to create custom.sh shell script in
# /etc/profile.d/ to make custom changes to environment. This will
# prevent need for merging in future updates.
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`id -u`
UID=`id -ru`
fi
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
pathmunge /sbin after
fi
HOSTNAME=`/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. $i
else
. $i >/dev/null 2>&1
fi
fi
done
unset i
unset pathmunge
LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
export HISTTIMEFORMAT="%F %T `whoami` "
"/etc/profile" 74L, 1568C written
[root@lvs2 ~]# ll
-bash: ll: command not found
[root@lvs2 ~]# source /etc/profile
[root@lvs2 ~]# ll
婊绋?288
-rw-r--r-- 1 root root 16860 11?16 19:01 1.txt
-rw-------. 1 root root 1334 11?12 13:05 anaconda-ks.cfg
-rw-r--r--. 1 root root 7934 11?12 13:05 install.log
-rw-r--r--. 1 root root 2964 11?12 13:04 install.log.syslog
drwxr-xr-x 7 1000 1000 4096 11?12 16:22 keepalived-1.2.2
-rw-r--r-- 1 root root 249557 1?17 2011 keepalived-1.2.2.tar.gz
drwxr-xr-x 2 root root 4096 11?12 15:15 network-conf
[root@lvs2 ~]#