Linux is a popular mainstream operating system linux Create administrator user If you need to configure a group of users in batches in the Linux system, the following will introduce how to create users in batches in Linux.
Method 1: Use Useradd commandUseradd is the default user creation tool that comes with the Linux system. You can use it to quickly create one or more users in the Linux system. To create a new user, just issue the following command:
useradd –m test<br>
–m can be omittedlinux creates an administrator user
to create a user called test. Multiple users can be created at the same time:
useradd -m test1 test2 test3<br>
Note that if you want to add multiple users in one command, you need to separate the user names with spaces. The previous example created three users: test1, test2, test3.
Tip 2: Use for loop
The for loop under Linux can also be used to create users in batches, such as the following example:
for i in {1..5} ; do useradd -m test$i ; done<br>
This command inside will manually create 5 users, namely test1, test2, test3, test4, test5.
Method 3: Use for loop and fields
If you need to create a user with a distinguished name in the Linux system, to extract a name like Chen Qi, you can use a linked list to store the name, and then use for loops and fields to create batch users. :
# 用户名字数组<br>nameArray=( LiNa MaYu LiLei )<br># for循环遍历用户名字for name in ${nameArray[@]}; do<br>useradd -m $namedone<br>
The code inside will create three users: LiNa, Mayu, and LiLei. ###In short, under Linux, you can create users in batches by using the useradd command, for loop and fields. This will greatly reduce the workload and improve efficiency for system administrators. ### ###
The above is the detailed content of How to implement batch creation of users in Linux? Order. For more information, please follow other related articles on the PHP Chinese website!