当前位置:网站首页>第三天作业
第三天作业
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
边栏推荐
- ORACLE 官方文档
- JSP built-in object (implicit object) -- input / output object
- Burp Suite - Chapter 1 burp suite installation and environment configuration
- Abstract classes and interfaces
- The idea of stack simulating queue
- Dev gridcontrol captures key events
- 万字长文 | 深入理解 OpenFeign 的架构原理
- 2022/7/11 exam summary
- The difference between LinkedList and ArrayList
- Ten thousand words long article | deeply understand the architecture principle of openfeign
猜你喜欢

This is a picture

Spotty music data client_ ID account
![[fastjson1.2.24 deserialization vulnerability principle code analysis]](/img/14/8f6a75fe5f06c19eeff9c7204979c3.png)
[fastjson1.2.24 deserialization vulnerability principle code analysis]

File parsing (JSON parsing)

The most complete network: detailed explanation of six constraints of MySQL

数组的介绍--Array

2022-07-13 group 5 Gu Xiangquan's learning notes day06

Rack server expansion memory

Excel file reading and writing (creation and parsing)

利用js实现统计字符串数组中各字符串出现的次数,并将其格式化为对象数组。
随机推荐
Burp suite Chapter 4 advanced options for SSL and proxy
Introduction to C language (8)
吉他五线谱联系 茉莉花
要不你给我说说什么是长轮询吧?
PHP environment deployment
Lnmp+wordpress to quickly build a personal website
NFS service and Samba service deployment
JSP built-in object (implicit object)
Burp Suite - Chapter 2 burp suite proxy and browser settings
咱就是来聊聊并发编程的三大核心问题。
Copy pcap file with producer consumer model
Lambda and stream
This is a picture
小蜜蜂吉他谱 高八度和低八度
2022/7/12 exam summary
The difference between overloading and rewriting
2022-07-08 group 5 Gu Xiangquan's learning notes day01
Burp suite Chapter 9 how to use burp repeater
Reading and writing properties file
Implementation class under map interface