顯示文章

這裡允許您檢視這個會員的所有文章。請注意, 您只能看見您有權限閱讀的文章。


主題 - rita299

頁: [1]
1
想請教如何寫一個BASH SCRIPT create a user and a group(if the group is not exist)

#!bin/bash
read -p "Enter USERNAME: " userNAME
read -p "Enter USERGROUP name: " userRGROUP

grep $USERGROUP /etc/group 2>&1> /dev/null

while [ $? -eq 0 ]
        read -p "Enter USERNAME: " userNAME
        read -p "Enter USERGROUP name: " userRGROUP
grep $USERGROUP /etc/group 2>&1> /dev/null
        printf "Group Name you entered $USERGROUP is not valid\n"
        printf "Creating Abort!"\n"
        exit 1
do
        useradd -g $USERGROUP -d /home/$USERNAME -s /bin/bash -m $USERNAME
        passwd $USERNAME
done

id $USERNAME

printf "Done!\n"

exit 0

頁: [1]