Create a User for Linux

Sh file and grant vi adduser.sh chmod +x adduser.sh

The script content is as follows:

#! /bin/bash # create a new user with the same password as the user name. #2. Execute silently, except for a message indicating success or failure.

[! $# -eq 1] && echo “args error!!” && exit 2

Id $1 >&/dev/null && echo “user exist” && exit 3

# to create user, create a successful exit useradd 1 > & / dev/null && echo 1 | passwd — stdin $1 > & / dev/null && echo “user the add success” && exit 4

Echo “– user add fail!! —” && exit 5

Note: 1. Create a user as user root. 2. The script format is./adduser.sh newusername or sh adduser.sh newusername