Script to grab all the domain groups for a user on a Linux system with Active Directory connection






#Reseting String storage veribles




echo “command line to usergroup checker

please supply the domain you wish to check”

read DOM

DOMAIN=$(echo $DOM | tr [a-z] [A-Z])


echo “What username do you wish to list groups for?”



USERSID=$(WINBINDD_SOCKET_DIR=/var/samba/$DOMAIN/ wbinfo –name-to-sid=$USERNAME &> $USIDTEMP)

echo “check Remote Proceedure Call (RPC) connection to domain”

echo ” “

WINBINDD_SOCKET_DIR=/var/samba/$DOMAIN/ wbinfo -t

echo ” “

echo “———————————————————“

echo ” “

echo “Current Domain Controller Bound To”

echo ” “

WINBINDD_SOCKET_DIR=/var/samba/$DOMAIN/ wbinfo –dc-info=$DOMAIN

echo ” “

echo “———————————————————“

echo ” “

echo “Check All List Domain In $DOMAIN current Status: “

echo ” “

WINBINDD_SOCKET_DIR=/var/samba/$DOMAIN/ wbinfo –online-status

echo ” “

echo “———————————————————“

echo ” “

echo ” “

#Save the username sid to a tmp file

WINBINDD_SOCKET_DIR=/var/samba/$DOMAIN/ wbinfo –name-to-sid=$USERNAME &> $USIDTEMP

#Read in the USID

cat $USIDTEMP | while read LINE


USERSID=$(echo $LINE | gawk ‘{print $1}’)

echo ” “

echo “Groups found for $USERNAME are:”

echo ” “

GROUPSID=$(WINBINDD_SOCKET_DIR=/var/samba/$DOMAIN/ wbinfo –user-sids=$USERSID &> $GSIDTEMP )

cat $GSIDTEMP | while read GLINE



TEST=$(WINBINDD_SOCKET_DIR=/var/samba/$DOMAIN/ wbinfo –sid-to-name=$GLINE &> $NAMETEMP)

cat $NAMETEMP | gawk ‘BEGIN{FS=”\\”}{print $1″,”$2}’ | while read NLINE


T=$(echo $NLINE | rev | cut -c1)

if [ $T = 2 ]; then

echo $NLINE | gawk ‘BEGIN{FS=”,”}{print $1″\\”$2}’|sed ‘s/.$//’





Common Linux Commands


#ping -I ethF (from a particular source interface)


#/sbin/ifconfig (all active network interfaces and some interface statistics)(add or change IP addresses)

# ifconfig -a

# ip addr

#setup (to change the default interface or changing the interface IPs etc)


#clear (to clear the screen)

#ip neigh flush all (clear arp cache)


#dig (just like nslookup in windows)


#route -n (or route (to print the routing table in linux)

#route add default gw eth0 (to add a default route)

#route add -net netmask gw

#route del -net netmask gw

System information commands

#vmstat (summary information for system load and usage, but does not show individual processes)

#ps aux (display all processes running on the Linux system)(to search for specific processes or list them all)

#ps aux | grep auth (all the processes that have auth in them)

#ps auxf | sort -nr -k 4 | head -10 (shows the top 10 memory consuming processes)

#cat /proc/cpuinfo (lot of information about the system and the hardware associated)

#cat /proc/meminfo (information on memory and memory usage)

#cat /proc/mounts (various file systems and where they are mounted and which options have been used)

#df -h (Show a summary of disk usage and some useful key combinations Keyboard Combinations SHIFT + PAGE UP scroll up the screen CTRL + C stop a running command eg ping)