Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mass production users in UNIX environment

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Linux environment:

1. Write a file: passwd.list. The goal is for computers to recognize user names.

vi passwd.list

#!/ bin/sh

sum=1

while [ $sum -le 100 ]

do

echo "user$sum::'expr $sum + 100':'expr $sum +100'::/home/user$sum:/bin/sh\n" >> /etc/passwd

sum='expr $sum + 1'

done

:wq!

This will generate the passwd.list file, but in this case, it is not executable, to execute, you need to do the following work:

# chmod 777 passwd.list

(chmod for Grant Permission Command, 777 for Everyone Can Have Permission)

# ./ passwd.list

(To be executed in the directory where the file is located)

passwd.list adds 100 users from user1 to user100 to the/etc/passwd file.

In this example, the user name is: user1----user100

User ID: n+100 (the number following no user, i.e., the user ID of user1 is 101)

Group ID: Same as user ID.

Note: 1) In Linux 7.0, this example:

echo "user$sum::`expr $sum + 100`:`expr $sum +100`::/home/user$sum:/bin/sh\n" >> /etc/passwd changed to:

echo "user$sum::`expr $sum + 100`:`expr $sum +100`::/home/user$sum:/bin/sh" >> /etc/passwd

2)"There must be no blank space behind it, otherwise the system will not recognize the user name."

3)$sum spaces + spaces 100 (spaces must be present)

4)`is the key to the left of number 1 on the keyboard, not the key to the right of L

2. Write the file shadow.list to modify the real passwords of users under/etc/shadow.

Vi shadow.list

#!/ bin/sh

sum=1

while [ $sum -le 100 ]

do

echo "user$sum::::::::\n" >> /etc/shadow

sum='expr $sum + 1'

done

:wq!

This will generate a shadow.list file, but at this time, it is not executable, to execute, you need to do the following work:

# chmod 777 shadow.list

# ./ shadow.list

In this way, shadow.list changes the user's password, in this case, set to empty, no password.

Note: 1) In "user$sum::::::\n",: is 8

2)$sum spaces + spaces 1

3) Note the key

3. Generate a dir.list file, the purpose is to establish the user's corresponding host directory, that is, the directory.

Vi dir.list

cd /home

sum=1

while [ $sum -le 100 ]

do

mkdir user$sum

sum='expr $sum + 1'

done

chown user$sum user$sum

:wq!

# chmod 777 dir.list

#./ dir.list

Note: Same as 1.2

********* Note: If the system is Solaris, 1.3 in the above file is different. As follows:

1. Vi passwd.list

#!/ bin/sh

sum=1

whole [ $sum + 1 ]

do

echo "user$sum::`expr $sum + 100`:`expr $sum +100`::/export/home/user$sum:/bin/sh\n" >> /etc/passwd

sum=`expr $sum + 1`

done

:wq!

3. Vi dir.list

cd /export/home

sum=1

while [ $sum -le 100 ]

do

mkdir user$sum

sum=`expr $sum + 1`

chown user$sum user$sum

done

:wq!

# chmod 777 dir.list

#./ dir.list

After the completion of the implementation, Solaris system login, you enter the user name, it will prompt you to set a password, click OK, re-set the password, and then re-login, you can enter.

Linux system after entering the user name, both can directly enter the system.

This example is used for batch establishment of users, and the password is empty. I am also in such a need, learn to write their own, inevitably have a proper place, please correct me. Progress together.

Viking_lee

cd /home

sum=1

while [ $sum \u2013le 100 ]

do

mkdir user$sum

sum='expr $sum + 1'

done

chown user$sum user$sum

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report