您现在的位置是:网站首页> 编程资料编程资料
linux系统中的列出敏感用户的脚本代码_linux shell_
2023-05-26
345人已围观
简介 linux系统中的列出敏感用户的脚本代码_linux shell_
此处的敏感用户是指这个用户属于多个组,或者这个用户属于的组名跟这个用户名不一样
#! /bin/bash #list user who belong to more than one group #and list user who belong to the group which isn't the same as the username #w is whitelist,we will not think user in this whitelist is special or dangerous w=("root" "adm" "games" "operator" "halt" "shutdown" "sync" "daemon" "bin" "operator") function WhiteList() { for i in ${w[@]} do if [ "$i" == "$1" ];then return 1 fi done return 0 } IFS=" " for LINE in `cat /etc/passwd|awk -F: '{print $1}'` do WhiteList $LINE; #if $? equal 1,means it is in the whitelist if [ $? -eq 0 ];then a=`groups $LINE|awk -F: '{print $2}'` b=`echo $a` if [ "$b" != "$LINE" ];then #echo $LINE echo `groups $LINE` fi fi done
相关内容
- shell脚本中执行python脚本并接收其返回值的例子_linux shell_
- shell脚本实现拷贝大文件显示百分比的代码分享_linux shell_
- Shell脚本实现自动发送邮件的例子_linux shell_
- 自己常用的一些shell脚本分享_linux shell_
- awk中实现ord函数功能_linux shell_
- CentOS下redis自启动shell脚本_linux shell_
- 收集的48个Shell脚本小技巧_linux shell_
- shell脚本连接、读写、操作mysql数据库实例_linux shell_
- Shell+Linux命令实现日志分析_linux shell_
- Linux中执行shell脚本的4种方法总结_linux shell_
