当前位置:网站首页>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 是否存在

验证:
边栏推荐
- 2022-08-01 回顾基础二叉树以及操作
- MQTT X Newsletter 2022-07 | 自动更新、MQTT X CLI 支持 MQTT 5.0、新增 conn 命令…
- There is only one switch, how to realize the nqa of master-slave automatic switching
- Assembly language (8) x86 inline assembly
- sql server收缩日志的作业和记录,失败就是因为和备份冲突了吗?
- leetcode refers to Offer 10- II. Frog jumping steps
- Comprehensively explain what is the essential difference between GET and POST requests?Turns out I always misunderstood
- Moonbeam团队发布针对整数截断漏洞的紧急安全修复
- 百行代码发射红心,程序员何愁命不中女朋友!
- PAT乙级-B1019 数字黑洞(20)
猜你喜欢

Creo 9.0 基准特征:基准坐标系

基于 Kubernetes 的微服务项目整体设计与实现

Two-table query average grouping in sql server

百行代码发射红心,程序员何愁命不中女朋友!

Detailed explanation of DNS query principle

【LeetCode】623. Add a row to the binary tree

2022.8.3

Hundred lines of code launch red hearts, why programmers lose their girlfriends!

营销建议 | 您有一份八月营销月历待查收! 建议收藏 !

欧盟 | 地平线 2020 ENSEMBLE:D2.13 SOTIF Safety Concept(上)
随机推荐
PAT乙级-B1020 月饼(25)
网页直接访问链接不让安全中心拦截
Hundred lines of code launch red hearts, why programmers lose their girlfriends!
selectPage 动态改变参数方法
Comprehensively explain what is the essential difference between GET and POST requests?Turns out I always misunderstood
egg framework
【ASM】字节码操作 方法的初始化 Frame
Thinking and summary of the efficiency of IT R&D/development process specification
The Secrets of the Six-Year Team Leader | The Eight Most Important Soft Skills of Programmers
2.4G无线收发模块的应用
Luogu: P2574 XOR的艺术 [线段树]
代码审计—PHP
C语言-数组
thinkPHP5 实现点击量(数据自增/自减)
Creo 9.0 基准特征:基准坐标系
Dynamic memory development (C language)
哪个是你爱情的颜色?
【Excel实战】--图表联动demo_001
tensorflow.keras cannot introduce layers
接口全周期的生产力利器Apifox