#!/bin/bash # auth: xiluhua # date: 2017-02-26 read -p "please input a username:" username [ -z $username ] && echo "a username is needed" && exit 2 if id $username &> /dev/null then echo $username 'is exist' fi read -p "please input the passward:" passward [ -z $passward ] && echo "a passward is needed" && exit 3 useradd $username echo "$passward" | passwd --stdin $username &> /dev/null echo "add $username finished"