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

验证:
边栏推荐
- 并发之CAS
- Chapter 12 Bayesian Networks
- Excuse me, guys, is it impossible to synchronize two databases in real time using Flink SQL CDC?
- tear apart loneliness
- XCODE12 在使用模拟器(SIMULATOR)时编译错误的解决方法
- 【Excel实战】--图表联动demo_001
- 【零基础玩转BLDC系列】无刷直流电机无位置传感器三段式启动法详细介绍及代码分享
- 【 a daily topic 】 1403. The increasing order of the sequence, boy
- (转)[Json]net.sf.json 和org.json 的差别及用法
- k-nearest neighbor fault monitoring based on multi-block information extraction and Mahalanobis distance
猜你喜欢

Pagoda measurement - building small and medium-sized homestay hotel management source code

Overall design and implementation of Kubernetes-based microservice project

Assembly language (8) x86 inline assembly

【ASM】字节码操作 方法的初始化 Frame

MySQL内部函数介绍

C语言-数组

SQL语句查询字段内重复内容,并按重复次数加序号

并发之CAS

eKuiper Newsletter 2022-07|v1.6.0:Flow 编排 + 更好用的 SQL,轻松表达业务逻辑

The Coolest Kubernetes Network Solution Cilium Getting Started Tutorial
随机推荐
DPU — 功能特性 — 存储系统的硬件卸载
The Seven Weapons of Programmers
工程制图知识点
2022-08-01 回顾基础二叉树以及操作
Hbuilder 学习使用中的一些记录
selectPage 动态改变参数方法
画法几何及工程制图考试卷A卷
Weekly Report 2022-8-4
ts/js 函数传参带函数写法
动态库之间回调函数使用
flink cdc支持从oracle dg库同步吗
PAT乙级-B1021 个位数统计(15)
Concurrent CAS
Is there a problem with writing this?How to synchronize data in sql-client
sphinx matches the specified field
动态内存开辟(C语言)
明天去订票,准备回家咯~~
在colab里怎样读取google drive数据
Why do I recommend using smart async?
Dynamic memory development (C language)