Get the App
SLTechnology News&Howtos  ›  Servers  › 

Write a script to delete 100 users

Shulou Source: shulou.com Published: 2022-06-02 12:19:47 10月03日 Update

#! / bin/bash

For USER in user {1... 100} # variable USER loops from user1 to user100, generating 100 users

Do

If id $USER & > / dev/null # if the user exists

Then # and then

Userdel-r $USER # Delete user

Echo "$USER delete successful." # hint: user deleted successfully

Else # and then

Echo "$USER already exit" # hint: user does not exist

Fi

Done

Tags: User prompt success variable Loop Generation script Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Apple NVidia OPPO Reno MariaDB