![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Permission denied, but user is owner and has group ownership too | scottrus | UNIX for Advanced & Expert Users | 6 | 08-24-2009 03:38 AM |
| UNIX home directories | zainster | UNIX for Dummies Questions & Answers | 7 | 07-21-2009 06:06 AM |
| Batch delete specific folder from user home directories | nipodrom | Shell Programming and Scripting | 2 | 05-09-2008 07:22 AM |
| How to backup /home directories? | kingsan | SUN Solaris | 1 | 05-03-2006 06:41 PM |
| Delete old home directories | munch | UNIX for Dummies Questions & Answers | 2 | 03-02-2006 01:16 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to verify all user home directories are writable only by their owner
Hi, I'm currently working on my school assignment on how to verify that all user home directories are writable only by their owner on Solaris with VMware. But I'm not sure why my codes take a very long time to display the results. My friend says it's the `su - $i -c "ls -ld" 2> /dev/null | grep ^d | awk '{print $1}'` part that is causing the problem but his not sure what to do either. Can someone please help me? Thanks.
#!/usr/bin/bash clear echo " Verifying if user home directories are writable only by their owner" echo TEMPFILE=/permgrep.txt TEMPFILE2=/namegrep.txt accno=0 h=1 no=1 Ps=0 Fs=0 if [ ! -f ${TEMPFILE} ] then touch ${TEMPFILE} fi if [ ! -f ${TEMPFILE2} ] then touch ${TEMPFILE2} fi ACCOUNTS=`cat /etc/passwd | awk -F: '{print $1}'` array=($ACCOUNTS) for i in "${array[@]}" do let "accno += 1" PRINTER=`su - $i -c "ls -ld" 2> /dev/null | grep ^d | awk '{print $1}'` if [ -n "$PRINTER" ] then echo $PRINTER >> $TEMPFILE echo $i >> $TEMPFILE2 fi done echo for line in $(cat /permgrep.txt) do READTF2=`head -$h /namegrep.txt | tail -1` if [ $line == 'drwxr-xr-x' ] then echo $no"-"$READTF2": PASS" let "h += 1" let "Ps += 1" else echo $no"-"$READTF2": FAIL" let "h += 1" let "Fs += 1" fi let "no += 1" done nohodi=`expr $accno - $Ps - $Fs` echo " Total user accounts: "$accno echo " Pass: "$Ps echo " Fail: "$Fs echo " no home directory : "$nohodi rm /namegrep.txt rm /permgrep.txt |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|