-------------------------------------------------------------------------------

 

this name 123.sh

***************************************
for  mum in $(seq 1 10)
do
USER=admin$mum
useradd $USER
echo "password" |passwd --stdin $USER
done
~
~
***************************************

chmod u+x 123.sh

 

 [root@rhce ~]# ./123.sh
Changing password for user admin1.
passwd: all authentication tokens updated successfully.
Changing password for user admin2.
passwd: all authentication tokens updated successfully.
Changing password for user admin3.
passwd: all authentication tokens updated successfully.
Changing password for user admin4.
passwd: all authentication tokens updated successfully.
Changing password for user admin5.
passwd: all authentication tokens updated successfully.
Changing password for user admin6.
passwd: all authentication tokens updated successfully.
Changing password for user admin7.
passwd: all authentication tokens updated successfully.
Changing password for user admin8.
passwd: all authentication tokens updated successfully.
Changing password for user admin9.
passwd: all authentication tokens updated successfully.
Changing password for user admin10.
passwd: all authentication tokens updated successfully.

 

[root@rhce ~]# more /etc/passwd

admin1:x:517:517::/home/admin1:/bin/bash
admin2:x:518:518::/home/admin2:/bin/bash
admin3:x:519:519::/home/admin3:/bin/bash
admin4:x:520:520::/home/admin4:/bin/bash
admin5:x:521:521::/home/admin5:/bin/bash
admin6:x:522:522::/home/admin6:/bin/bash
admin7:x:523:523::/home/admin7:/bin/bash
admin8:x:524:524::/home/admin8:/bin/bash
admin9:x:525:525::/home/admin9:/bin/bash
admin10:x:526:526::/home/admin10:/bin/bash

 

------------------------------------------------------------------------------------

this name 456.sh

******************************************************************

for n in {1..20}; # or $(seq 1 20)#
do
host=192.168.137.$n
ping -c2 $host &> /dev/null  #ping two seq data---c2
if [ $? = 0 ]; then  # $? is the results of previous ,0 is pass 1-255 is fail #
 echo "$host is UP"
else
 echo "$host is DOWN"

fi
done

*****************************************************************

[root@rhce ~]# ./456.sh
192.168.137.1 is UP
192.168.137.2 is DOWN
192.168.137.3 is DOWN
192.168.137.4 is DOWN
192.168.137.5 is DOWN
192.168.137.6 is DOWN
192.168.137.7 is DOWN
192.168.137.8 is DOWN
192.168.137.9 is DOWN
192.168.137.10 is DOWN
192.168.137.11 is DOWN
192.168.137.12 is DOWN
192.168.137.13 is DOWN
192.168.137.14 is DOWN
192.168.137.15 is DOWN
192.168.137.16 is DOWN
192.168.137.17 is DOWN
192.168.137.18 is DOWN
192.168.137.19 is DOWN
192.168.137.20 is DOWN

 

--------------------------------------------------------------------------------------