文章目录
Ubuntu关闭dash
正常情况下,Ubuntu执行let会有报错提示命令未找到
这是因为Ubuntu默认的shell在真正执行的时候指向的dash,因此需要关闭dash,才能使脚本在bash下运行,关闭dash操作如下
root@seafile-0823:~# sudo dpkg-reconfigure dash
在弹出的窗口选择NO
上脚本
统计用户shell类型及对应数量
root@seafile-0823:~# cat arr.sh
#!/bin/bash
declare -A login
while read line ;do
type=`echo $line |awk -F: '{print $NF}'`
let login[$type]++
done < /etc/passwd
for i in ${!login[*]};do
echo "登录类型:$i 登录数量:${login[$i]}"
done
执行一下看看效果
root@seafile-0823:# chmod +x arr.sh
root@seafile-0823:# ./arr.sh
登录类型:/bin/bash 登录数量:2
登录类型:/bin/false 登录数量:3
登录类型:/usr/sbin/nologin 登录数量:29
登录类型:/bin/sync 登录数量:1