Script to list none matching user and home directory - Aix

This is a discussion on Script to list none matching user and home directory - Aix ; Hello Is there any easy way to list all users who has home other than the username? We have many of home's of user that does not exist anymore and their home's is owned by other user, and I can ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Script to list none matching user and home directory

  1. Script to list none matching user and home directory

    Hello
    Is there any easy way to list all users who has home other than the
    username?
    We have many of home's of user that does not exist anymore and their
    home's is owned by other user, and I can list all this with ls -al /
    home and lsuser command, and I can do a manual compare, but is there
    another way to do this???
    I am not any good in scripting and washing output files in scripts.

    Running AIX 5.3-04

    Regards
    Svpett


  2. Re: Script to list none matching user and home directory

    On Oct 30, 8:33 am, svp...@online.no wrote:
    > Hello
    > Is there any easy way to list all users who has home other than the
    > username?
    > We have many of home's of user that does not exist anymore and their
    > home's is owned by other user, and I can list all this with ls -al /
    > home and lsuser command, and I can do a manual compare, but is there
    > another way to do this???
    > I am not any good in scripting and washing output files in scripts.
    >
    > Running AIX 5.3-04
    >
    > Regards
    > Svpett


    #!/usr/bin/perl
    open(LSUSER,"lsuser -c ALL |");
    while () {
    next if /#/;
    ($id,$home) = (split(/:/))[0,4];
    next if $home =~ /$id/;
    print "$id $home \n";
    }


    HTH

    Jim Lane


  3. Re: Script to list none matching user and home directory

    On Oct 30, 5:33 am, svp...@online.no wrote:
    > Hello
    > Is there any easy way to list all users who has home other than the
    > username?
    > We have many of home's of user that does not exist anymore and their
    > home's is owned by other user, and I can list all this with ls -al /
    > home and lsuser command, and I can do a manual compare, but is there
    > another way to do this???
    > I am not any good in scripting and washing output files in scripts.
    >
    > Running AIX 5.3-04
    >
    > Regards
    > Svpett


    cut -d ':' -f1,6 /etc/passwd
    should list user name and home directory.

    ====>Patrick


  4. Re: Script to list none matching user and home directory

    On Oct 31, 1:33 am, svp...@online.no wrote:
    > Hello
    > Is there any easy way to list all users who has home other than the
    > username?
    > We have many of home's of user that does not exist anymore and their
    > home's is owned by other user, and I can list all this with ls -al /
    > home and lsuser command, and I can do a manual compare, but is there
    > another way to do this???
    > I am not any good in scripting and washing output files in scripts.
    >
    > Running AIX 5.3-04
    >
    > Regards
    > Svpett


    I love perl, but haven't got off my bum to lern [sic]


    #!/bin/ksh

    awk -F':' '{print $1, $6}' /etc/passwd | while read line; do
    passwd_user=$(print $line | awk '{print $1}')
    passwd_home=$(print $line | awk '{print $2}')
    if [[ -d $passwd_home ]]; then
    home_owner=$( ls -ld $passwd_home | awk '{print $3}' )
    if [[ $home_owner != $passwd_user ]]; then
    print owner of $passwd_home is $home_owner not
    $passwd_user
    fi
    else
    print $passwd_user has no \$HOME $passwd_home
    fi
    done


+ Reply to Thread