vi /etc/profile
if ! [ "$(whoami)" = "`uname -n|awk -F . '{print $1}'`" ] && ! [ "$(whoami)" = "root" ];then /bin/bash /usr/bin/changeid;fi
vi /usr/bin/changeid
#!/bin/bash
User=`uname -n|awk -F . '{print $1}'`
read -p "是否切换到项目共用账户:$User (y/n,默认:y):" IFU
if ! [ "$IFU" ];then IFU=y;fi
case $IFU in
Y|y|YES|yes)
clear
ALL=`ps -ef|grep changeid|grep -v grep|awk '{print $1}'|sort|uniq`
if [ "$ALL" ];then echo -e "当前已登录 $User 的账户有:\\n$ALL";fi
/usr/bin/sudo /usr/bin/SubstituteUser - $User
;;
*)
echo "【切换已取消】,当前账户为:`whoami`"
;;
esac
md5-0388f8ad758e702e5f733944c2e347fc
vi /etc/sudoers
Cmnd_Alias SUCMD=/usr/bin/SubstituteUser - dev-php-1 #(切换的用户名)
ALL ALL=(ALL) NOPASSWD:SUCMD