For add user

Source: Internet
Author: User

Add 10 users user1 to User10, password with user name, but only if the user does not exist in the case can be added;
Accept a parameter:
Add: Adding User user1. User10
Del: Delete User user1. User10
Other: Exit

Code #!/bin/bash#a=$1if [  $A  == add ];then  for i in {1..10};d o     USER=user$I    if ! id  $USER  &> / dev/null ;then      useradd user$i &> /dev/null       echo  "User$i"  | passwd user$i --stdin &>/ dev/null      echo  "Add user$i ok"     else       echo  "User$i ex"     fi  doneelif  [  $A  == del ];then  for i in {1..10};d o     USER=user$I    if id  $USER  &>/dev/null ;then       userdel user$i         \rm -r  /home/user$i       echo  "Delete user$i ok"     else        echo  "User$i is not ex"     fi   doneelse  echo  "usage: ./foruseradd.sh " add   "de" "fi


For add user

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.