【原创】增加用户组和用户的shell
#! /bin/bash
clear
export LANG=zh_CN.GB2312
export LANG=zh_CN.GB2312
group_oinstall=`grep oinstall /etc/group`
group_dba=`grep dba /etc/group`
group_dba=`grep dba /etc/group`
# check login root
if [ $LOGNAME != "root" ]
then
echo "login user is not root!"
exit
fi
if [ $LOGNAME != "root" ]
then
echo "login user is not root!"
exit
fi
echo "===create group (oinstall,dba)==="
if [ "a"$group_oinstall != "a" ]
then
echo -e "\toinstall group is exists!"
else
groupadd oinstall
echo -e "\toinstall group is created!"
fi
then
echo -e "\toinstall group is exists!"
else
groupadd oinstall
echo -e "\toinstall group is created!"
fi
if [ "a"$group_dba != "a" ]
then
echo -e "\tdba group is exists!"
else
groupadd dba
echo -e "\tdba group is created!"
fi
echo -e "\n===create user (oracle)==="
id oracle >& /dev/null
if [ $? = 0 ]
then
echo -e "\toracle is exists!"
else
useradd oracle -g oinstall -G dba
echo oracle|passwd --stdin oracle > /dev/null
echo -e "\toracle is created!"
fi
id oracle >& /dev/null
if [ $? = 0 ]
then
echo -e "\toracle is exists!"
else
useradd oracle -g oinstall -G dba
echo oracle|passwd --stdin oracle > /dev/null
echo -e "\toracle is created!"
fi
echo -e "\n============done."