当前位置:网站首页>shell-第五章作业
shell-第五章作业
2022-07-25 10:28:00 【weixin_51808099】
- 使用case实现成绩优良差的判断
[[email protected] zuoye]# vim 5.1.sh
#1/bin/bash
read -p "please input your grade:" grade
case $grade in
8[5-9]|9[0-9]|100)
echo "A"
;;
7[0-9]|8[0-4])
echo "B"
;;
6[0-9])
echo "C"
;;
*)
echo "D"
esac
- for创建20用户
用户前缀由用户输入
用户初始密码由用户输入
例如:test01,test10
[[email protected] zuoye]# vim 5.2.sh
#!/bin/bash
a=0
for i in `seq 15`
do
read -p "please input your name :" name
if [ "$i -lt 10" ];then
useradd $name$a$i
passwd $name$a$i
else
useradd $name$i
passwd $name$i
fi
done
- for ping测试指网段的主机
网段由用户输入,例如用户输入192.168.2 ,则ping 192.168.2.10 — 192.168.2.20
UP: /tmp/host_up.txt
Down: /tmp/host_down.txt
[[email protected] zuoye]# vim 5.3.sh
#!/bin/bash
read -p "please input your IP: " IP
for i in `seq 120 130`
do
ping -c2 $IP.$i &>/dev/null
if [ $? -eq 0 ];then
echo $IP.$i >> ./host_up.txt
else
echo $IP.$i >> ./host_down.txt
fi
done
- 使用for实现批量主机root密码的修改
成功或失败都必须记录
提示:主机IP存放在一个文件中
SSH:实现公钥认证,执行远程中主机命令
实现公钥认证ssh-keygen 在用于管理的主上生成密钥对
ssh-copy-id -i 192.168.2.3
[[email protected] zuoye]# vim 5.4.sh
#!/bin/bash
for i in `grep ^1 hostip`
do
echo "you will change the [email protected]$i'passwq "
ssh $i passwd root
if [ $? -eq 0 ];then
echo "[email protected]$i'passwd was change" >> hps
else
echo "[email protected]$i'passwq is not change" >> hpf
fi
done
边栏推荐
- 【IJCAI 2022】参数高效的大模型稀疏训练方法,大幅减少稀疏训练所需资源
- JS 将伪数组转换成数组
- C3d model pytorch source code sentence by sentence analysis (II)
- MySQL | GROUP_CONCAT函数,将某一列的值用逗号拼接
- 【高并发】通过源码深度分析线程池中Worker线程的执行流程
- JS bidirectional linked list 02
- The most detailed MySQL index analysis (mind map is attached at the end of the article)
- How can you use unity without several plug-ins? Unity various plug-ins and tutorial recommendations
- Esp32c3 based on the example tutorial of esp32 Rainmaker development under Arduino framework
- txt转csv文件,隔行出现空行
猜你喜欢

Learn NLP with Transformer (Chapter 5)
Learn NLP with Transformer (Chapter 3)

Nb-iot control LCD (date setting and reading)

HCIP(12)

NowCoderTOP12-16——持续更新ing

HCIP(13)

I, AI doctoral student, online crowdfunding research topic

Reinforcement learning (III)

Code representation learning: introduction to codebert and other related models

How can you use unity without several plug-ins? Unity various plug-ins and tutorial recommendations
随机推荐
2021 CEC written examination summary
Openstack skyline component installation
Reinforcement Learning 强化学习(四)
Learn NLP with Transformer (Chapter 3)
Nb-iot control LCD (date setting and reading)
Code representation learning: introduction to codebert and other related models
Flask框架——消息闪现
Learn NLP with Transformer (Chapter 5)
Google Earth Engine——统计逐年土地分类的频率
How to notify users of wechat applet version update?
Shell 脚本参数传递时有 \r 换行符问题
API supplement of JDBC
HCIA experiment (06)
NowCoderTOP7-11——持续更新ing
SQL语言(二)
HCIA experiment (07) comprehensive experiment
MLX90640 红外热成像仪测温模块开发笔记(五)
How can you use unity without several plug-ins? Unity various plug-ins and tutorial recommendations
[flask advanced] solve the classic error reporting of flask by combining the source code: working outside of application context
爬虫基础一