In as Administrator, from time to time will need to create users, but to create more user command parameters, so write a script to implement quickly create add_user.sh users.
#!/bin/bash if [ $# -ne 1 ]; then echo "Usage: $0 user-name" exit -1 fi # create a user useradd -g users -s /bin/bash -d /home/$1 -m $1 # set the password echo $1:$1 | chpasswd
create user in Linux useradd command:
-G users that the user belongs to users group
-S / bin / bash bash that users are logged on with
-D / home / $ 1 means that the user's home directory is created in / home /, the directory name with the same user name.
-M means that the user's home directory does not exist automatically created. Under normal circumstances no users, certainly not directory.
The final $ 1 is used to specify the user name created
Newly created user has no password, so by chpasswd command to specify the password with the username.
When you need to create user xyz, only to execute commands as root