Scripting code for sensitive users in Linux systems _linux Shell

Source: Internet
Author: User

A sensitive user here means that the user belongs to more than one group, or that the user belongs to a group name that is not the same as the user name.

#!  /bin/bash 
#list user who belong than one group 
#and list user who belong to the group which isn ' t the same As the username #w is whitelist,we would not do it 
whitelist is special or dangerous w= ("root" "ADM" gam Es "" Operator "" Halt "" Shutdown "" Sync "" Daemon "" Bin "" operator ") function WhiteList () 
{for- 
    I in ${w[@]} 
    do< c7/>if ["$i" = "$"];then return
            1 
        fi do return
    0 
} 
ifs= "for line in 
' Cat/etc/pa Sswd|awk-f: ' {print '} ' do
    WhiteList $LINE; 
    #if $? Equal 1,means It is in the whitelist     if [$-eq 0];then a=
        ' groups $LINE |awk-f: ' {print $} ' 
        b= ' echo $a ' 
        if ["$b"!= "$LINE"];then
            #echo $LINE             echo ' groups $LINE ' 
        fi
    fi done
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.