shell脚本编写不能登陆系统用户

环境准备
准备一台Centos6服务器
系统: Centos6.8
内存:1G
cpu: 2核
IP地址: 10.0.0.21
# 创建shell脚本
vim user.sh 
#!/bin/bash
total_num=`cat /etc/passwd | wc -l`
user_num=`cat /etc/passwd | grep '/bin/bash' | wc -l`
nologin_user=$(($total_num-$user_num))

echo "不能登陆系统的用户: $nologin_user"                                    
# 执行脚本
sh user.sh 

在这里插入图片描述

发布了68 篇原创文章 · 获赞 24 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/aaronszm/article/details/103773266
今日推荐