当前位置:网站首页>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 是否存在
验证:
边栏推荐
- 国际原子能机构总干事称乌克兰扎波罗热核电站安全形势堪忧
- tear apart loneliness
- How to replace colors in ps, self-study ps software photoshop2022, replace one color of a picture in ps with another color
- selectPage 动态改变参数方法
- 15.1.1、md—md的基础语法,快速的写文本备忘录
- 深度学习21天——卷积神经网络(CNN):服装图像分类(第3天)
- 为什么我推荐使用智能化async?
- Why do I recommend using smart async?
- ts/js function pass parameter with function writing
- 十一道家常小菜详细攻略[图文并茂]
猜你喜欢
There is only one switch, how to realize the nqa of master-slave automatic switching
周报2022-8-4
Pagoda measurement - building small and medium-sized homestay hotel management source code
How to make a puzzle in PS, self-study PS software photoshop2022, PS make a puzzle effect
express hot-reload
2.4G无线收发模块的应用
2022.8.3
Assembly language (8) x86 inline assembly
Dynamic memory development (C language)
代码审计—PHP
随机推荐
selectPage 动态改变参数方法
16种香饭做法全攻略
Is there a problem with writing this?How to synchronize data in sql-client
【LeetCode】623. 在二叉树中增加一行
明天去订票,准备回家咯~~
国际原子能机构总干事称乌克兰扎波罗热核电站安全形势堪忧
8.4 Summary of the mock competition
16 kinds of fragrant rice recipes
Hundred lines of code launch red hearts, why programmers lose their girlfriends!
tensorflow.keras cannot introduce layers
15.1.1、md—md的基础语法,快速的写文本备忘录
六年团队Leader实战秘诀|程序员最重要的八种软技能 - 脸皮薄容易耽误事 - 自我营销
动态内存开辟(C语言)
leetcode points to Offer 10- I. Fibonacci sequence
DPU — 功能特性 — 管理系统的硬件卸载
浅谈自动采集程序及入库
【 a daily topic 】 1403. The increasing order of the sequence, boy
【LeetCode】623. Add a row to the binary tree
The color of life divine
Excuse me, guys, is it impossible to synchronize two databases in real time using Flink SQL CDC?