当前位置:网站首页>shell脚本实例
shell脚本实例
2022-08-05 09:07:00 【夒爘僭鐤螫】
目录
1、通过交互式方法新建用户useradd,当用户不存在时才可新建,用户存在时,提示用户已存在。
1、通过交互式方法新建用户useradd,当用户不存在时才可新建,用户存在时,提示用户已存在。
#!/bin/bash
read -p "创建新用户的用户名: " name
A=$(grep "$name" /etc/passwd | wc -l )
if [ $A -eq 0 ];then
useradd $name
read -p "请输入密码: " passwd
echo "$passwd" | passwd --stdin $name
echo "用户创建完成"
else
echo "$name用户已存在"
fi
2、使用for循环写出乘法口诀表
验证:
3、使用for循环画出三角形
验证:
4、使用for循环画出倒三角形
验证:
5、使用for批量新建新用户
①新建一个name.txt用户列表,输入新建的用户名。
②写脚本,且调用name.txt进行兴建用户
验证:
6、 批量删除用户(依赖于第五道题)
验证①
验证② 当用户已经删除,还执行删除会怎样?
7、检查ip 是否存在
验证:
边栏推荐
- 16 kinds of fragrant rice recipes
- (转)[Json]net.sf.json 和org.json 的差别及用法
- Creo 9.0 基准特征:基准轴
- 深度学习21天——卷积神经网络(CNN):天气识别(第5天)
- 动态库之间回调函数使用
- sphinx matches the specified field
- CVPR 2022 | 将X光图片用于垃圾分割,港中大(深圳)探索大规模智能垃圾分类
- Pagoda measurement - building small and medium-sized homestay hotel management source code
- PAT乙级-B1019 数字黑洞(20)
- Code Audit - PHP
猜你喜欢
随机推荐
16 kinds of fragrant rice recipes
How ali cloud storage database automatically to speed up the loading speed of www.cxsdkt.cn how to set up the case?
express hot-reload
上海控安技术成果入选市经信委《2021年上海市网络安全产业创新攻关成果目录》
ECCV 2022 Oral 视频实例分割新SOTA:SeqFormer&IDOL及CVPR 2022 视频实例分割竞赛冠军方案...
Overall design and implementation of Kubernetes-based microservice project
The Seven Weapons of Programmers
【LeetCode】623. Add a row to the binary tree
请问如果想往mysql里面写数据,直接用flink-connector-jdbc就可以吧,可是我在f
微信小程序请求封装
2022/8/4 考试总结
eKuiper Newsletter 2022-07|v1.6.0:Flow 编排 + 更好用的 SQL,轻松表达业务逻辑
基于 Kubernetes 的微服务项目整体设计与实现
使用稀疏 4D 卷积对 3D LiDAR 数据中的运动对象进行后退分割(IROS 2022)
随时牵手 不要随意分手[转帖]
CCVR eases heterogeneous federated learning based on classifier calibration
Is there a problem with writing this?How to synchronize data in sql-client
接口全周期的生产力利器Apifox
并发之CAS
Thinking and summary of the efficiency of IT R&D/development process specification