Shell Learning-delete users in bulk

Source: Internet
Author: User

Demand:

Bulk delete users using the For loop

[Email protected] ~]# Cat/etc/passwdroot:x:0:0:root:/root:/bin/bash. stu01:x:1001:1001::/home/stu01:/bin/bashstu02:x:1002:1002::/home/stu02:/bin/bashstu03:x:1003:1003::/home/stu03 :/bin/bashstu04:x:1004:1004::/home/stu04:/bin/bashstu05:x:1005:1005::/home/stu05:/bin/bashstu06:x:1006:1006::/ Home/stu06:/bin/bashstu07:x:1007:1007::/home/stu07:/bin/bashstu08:x:1008:1008::/home/stu08:/bin/bashstu09:x : 1009:1009::/home/stu09:/bin/bashstu10:x:1010:1010::/home/stu10:/bin/bash

Delete Stu01-stu10 in bulk


Script content:

#!/bin/bash #mp for i in '/usr/bin/echo stu{01..10} ' does userdel-r $i done

Execution process:

[[email protected] ~]# sh-x userdel.sh +/usr/bin/echo stu01 stu02 stu03 stu04 stu05 stu06 stu07 stu08 stu09 stu10+ for I in '/usr/bin/echo stu{01..10} ' "+ userdel-r stu01userdel:user ' stu01 ' does not exist+ for I in '/usr/bin/echo stu{01. . Ten} ' + userdel-r stu02userdel:user ' stu02 ' does not exist

Use for loop to delete the specified user at this point

Shell Learning-delete users in bulk

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.