当前位置:网站首页>第三天作业
第三天作业
2022-07-26 08:12:00 【三俩两】
- 使用case实现成绩优良差的判断
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创建20用户
用户前缀由用户输入
用户初始密码由用户输入
例如: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测试指网段的主机
网段由用户输入,例如用户输入192.168.2 ,则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.sh使用for实现批量主机root密码的修改
成功或失败都必须记录
提示:主机IP存放在一个文件中 SSH:
实现公钥认证,执行远程中主机命令
实现公钥认证 # ssh-keygen 在用于管理的主上生成密钥对
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
边栏推荐
- 一键部署LAMP和LNMP架构
- Team members participate in 2022 China multimedia conference
- 2022-07-13 group 5 Gu Xiangquan's learning notes day06
- utils 连接池
- Burp Suite-第七章 如何使用Burp Scanner
- Exam summary on June 27, 2022
- [fastjson1.2.24 deserialization vulnerability principle code analysis]
- Function default parameters, arrow functions, and remaining parameters in ES6 - explanation
- Idea settings set shortcut keys to convert English letters to case in strings
- 有点牛逼,一个月13万+
猜你喜欢

全网最全:Mysql六种约束详解

基础乐理 节奏联系题,很重要

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

Pycharm code specification tool flake8

Recurrence of strtus2 historical vulnerability

Idea settings set shortcut keys to convert English letters to case in strings

AQS implementation principle

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

Burp suite Chapter 7 how to use burp scanner

How WPS sets page headers page by page
随机推荐
R language foundation
The difference between equals() and = =
Implementation class under map interface
Burp Suite - Chapter 2 burp suite proxy and browser settings
Burp suite Chapter 7 how to use burp scanner
The idea of stack simulating queue
外卖小哥,才是这个社会最大的托底
JSP implicit object -- scope
Matlab-二/三维图上绘制黑点
This is a picture
PHP environment deployment
NFS service and Samba service deployment
有点牛逼,一个月13万+
Understand microservices bit by bit
给项目日志加上traceid
2022/7/1
小组成员参加2022中国多媒体大会
Exam summary on July 13, 2022
【 fastjson1.2.24反序列化漏洞原理代码分析】
The difference between abstract classes and interfaces