当前位置:网站首页>Day 3 homework
Day 3 homework
2022-07-26 08:13:00 【Two in three】
- Use case Realize the judgment of good and bad grades
vim 1.sh
#!/bin/bash
read -p "please input your score:" score
case $score in
[0-9]|[1-5][0-9])
echo "Grade is C"
;;
[6-8][0-9])
echo "Grade is B"
;;
9[0-9]|100)
echo "Grade is A"
;;
esac
bash 1.sh
- for establish 20 user
The user prefix is entered by the user
The user's initial password is entered by the user
for example :test01,test10
vim 2.sh
#!/bin/bash
read -p "pleace input user prefix:" a
read -p "pleace input user postfix:" b
for i in {
01..20}
do
user=$a$i
password=$b$i
if ! id -u $user &> /dev/null
then
useradd $user
echo $password | passwd --stdin $user &>/dev/null
else
echo "user is exist"
fi
done
bash 2.sh
for ping Test refers to the host of the network segment
The network segment is input by the user , For example, user input 192.168.2 , be ping 192.168.2.10 — 192.168.2.20
UP: /tmp/host_up.txt
Down: /tmp/host_down.txt
vim 3.sh #!/bini/bash read -p "pleace input ip network segment" a for i in { 2..4} do ip="$a.$i" echo $ip if ping -c 2 $ip &>/dev/null then echo "$ip is up" >> /tmp/host_up.txt else echo "$ip is down" >> /tmp/host_down.txt fi done bash 3.shUse for Realize batch host root Password modification
Success or failure must be recorded
Tips : host IP In a file SSH:
Implement public key authentication , Execute host commands in remote
Implement public key authentication # ssh-keygen Generate a key pair on the master for management
ssh-copy-id -i 192.168.2.3
vim 4.sh
#!/bin/bash
ssh-keygen -f /root/.ssh/id_rsa -P '' -q &>/dev/null
for ip in `cat ipfile`
do
echo $ip
ssh-copy-copy-id [email protected]$ip
done
for ip in `cat ipfile`
do
echo $ip
ssh [email protected] "echo redhat | passwd --stdin root" &>/dev/null
if [ "$?" -eq 0 ];then
echo "host $ip successfully update passwd"
else
echo "host $ip error update passwd"
fi
done
bash 4.sh
边栏推荐
- 咱就是来聊聊并发编程的三大核心问题。
- C# WinForm中PreviewKeyDown、KeyDown、KeyPress、KeyUp区别与联系
- 小蜜蜂吉他谱 高八度和低八度
- Unity metaverse (II), mixamo & animator hybrid tree and animation fusion
- One click deployment lamp and LNMP architecture
- Excel file parsing
- 2W word detailed data Lake: concept, characteristics, architecture and cases
- Burp Suite-第六章 如何使用Burp Spider
- JSP built-in object (implicit object)
- 这是一张图片
猜你喜欢

Burp Suite-第九章 如何使用Burp Repeater

How to determine the authenticity of the website you visit -- certificate system

咱就是来聊聊并发编程的三大核心问题。

Burp suite Chapter 9 how to use burp repeater

Let's talk about the three core issues of concurrent programming.

Master slave database deployment

Burp suite Chapter 6 how to use burp spider

Traversal mode of list, set, map, queue, deque, stack
![[xshell7 free download and installation]](/img/1f/7ac3e2c40c1b3ef2e7ce7403541972.png)
[xshell7 free download and installation]

分布式相关面试题总结
随机推荐
Official Oracle document
Common methods of string: construction method, other methods
Exam summary on June 27, 2022
Unity Metaverse(二)、Mixamo & Animator 混合树与动画融合
C# WinForm中PreviewKeyDown、KeyDown、KeyPress、KeyUp区别与联系
吉他五线谱联系 茉莉花
我,35岁了。
Dev gridcontrol 捕获按键事件
Summary of common methods of string
JSP built-in object (implicit object) -- input / output object
2022/7/11 exam summary
数组的介绍--Array
No valid host was found when setting up openstack to create an instance There are not enough hosts available. code:500
Burp suite Chapter 6 how to use burp spider
JSP action -- usebean action
Sort sort IP addresses
One click deployment lamp and LNMP architecture
Burp suite Chapter 5 how to use burp target
R language foundation
The difference between abstract classes and interfaces