profile文件整理

看到别人的好点子随时会进行相应修改:

  1 # /etc/profile
  2 
  3 # System wide environment and startup programs, for login setup
  4 # Functions and aliases go in /etc/bashrc
  5 
  6 # It's NOT a good idea to change this file unless you know what you
  7 # are doing. It's much better to create a custom.sh shell script in
  8 # /etc/profile.d/ to make custom changes to your environment, as this
  9 # will prevent the need for merging in future updates.
 10 
 11 pathmunge () {
 12     case ":${PATH}:" in
 13         *:"$1":*)
 14             ;;
 15         *)
 16             if [ "$2" = "after" ] ; then
 17                 PATH=$PATH:$1
 18             else
 19                 PATH=$1:$PATH
 20             fi
 21     esac
 22 }
 23 
 24 
 25 if [ -x /usr/bin/id ]; then
 26     if [ -z "$EUID" ]; then
 27         # ksh workaround
 28         EUID=`id -u`
 29         UID=`id -ru`
 30     fi
 31     USER="`id -un`"
 32     LOGNAME=$USER
 33     MAIL="/var/spool/mail/$USER"
 34 fi
 35 
 36 # Path manipulation
 37 if [ "$EUID" = "0" ]; then
 38     pathmunge /sbin
 39     pathmunge /usr/sbin
 40     pathmunge /usr/local/sbin
 41 else
 42     pathmunge /usr/local/sbin after
 43     pathmunge /usr/sbin after
 44     pathmunge /sbin after
 45 fi
 46 
 47 HOSTNAME=`/bin/hostname 2>/dev/null`
 48 HISTSIZE=1000
 49 if [ "$HISTCONTROL" = "ignorespace" ] ; then
 50     export HISTCONTROL=ignoreboth
 51 else
 52     export HISTCONTROL=ignoredups
 53 fi
 54 
 55 export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
 56 
 57 # By default, we want umask to get set. This sets it for login shell
 58 # Current threshold for system reserved uid/gids is 200
 59 # You could check uidgid reservation validity in
 60 # /usr/share/doc/setup-*/uidgid file
 61 if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
 62     umask 002
 63 else
 64     umask 022
 65 fi
 66 
 67 for i in /etc/profile.d/*.sh ; do
 68     if [ -r "$i" ]; then
 69         if [ "${-#*i}" != "$-" ]; then
 70             . "$i"
 71         else
 72             . "$i" >/dev/null 2>&1
 73         fi
 74     fi
 75 done
 76 
 77 unset i
 78 unset pathmunge
 79 
 80 #iptables 
 81 iptables -F
 82 iptables -X
 83 /etc/init.d/iptables stop
 84 
 85 
 86 #mount yum iso
 87 mount -o loop /iso/rhel-server-6.3-x86_64-dvd.iso /yum
 88 
 89 #history time user
 90 
 91 export  HISTTIMEFORMAT="`whoami`: %F %T:"
 92 
 93 #history user
 94 PS1="`whoami`@`hostname`:"'[$PWD]:'
 95 history
 96 USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'` 
 97 if [ "$USER_IP" = "" ]
 98 then
 99 USER_IP=`hostname`
100 fi
101 if [ ! -d /tmp/nor ]
102 then
103 mkdir /tmp/nor
104 chmod 777 /tmp/nor
105 fi
106 if [ ! -d /tmp/nor/${LOGNAME} ]
107 then
108 mkdir /tmp/nor/${LOGNAME}
109 chmod 300 /tmp/nor/${LOGNAME}
110 fi
111 export HISTSIZE=4096
112 DT=`date '+%Y:%m:%d %r'`
113 export HISTFILE="/tmp/nor/${LOGNAME}/${USER_IP} nor.$DT"
114 chmod 600 /tmp/nor/${LOGNAME}/*nor* 2>/dev/null

 

转载于:https://www.cnblogs.com/nortorm/p/3801740.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值