Oracle7 Administrator's Reference for UNIX

Contents Index Home Previous Next

Administering Login Home Directories

To add or move login home directories without modifying programs that refer to them, you must:

It is not necessary to record a pathname except in a central reference file, because a user's home directory can be derived:

Similarly, group memberships are computed from /etc/group. See the sample grpx script later in this section.

Note: Local general-purpose utilities such as these should be stored in the /var/opt/bin directory.

Sample lhd Script

#!/bin/sh
#
# lhd - print login home directory name for a given user
#
# SYNTAX
# lhd [login]
#
# Cary Millsap, Oracle Services
# @(#)1.1 (93/05/17)
prog=`basename $0`
if [ $# -eq 0 ] ; then
        login=`whoami`
elif [ $# -eq 1 ] ; then
        login=$1
else
        echo "Usage: $prog login" >$2
        exit 2
fi
nawk -F: '$1==login {print $6}' login=$login /etc/passwd

Sample grpx Script

#!/bin/sh
# grpx - print the list of users belonging to a given group
#
# Cary Millsap, Oracle Services
# @(#)1.1 (93/07/04)
prog=`basename $0`
if [ $# -ne 1 ] ; then
        echo "Usage: $prog group" >&2
        exit 2
fi
g=$1
# calculate group id of g
gid=`nawk -F: '$1==g {print $3}' g=$g /etc/group`
# list users whose default group id is gid
u1=`nawk -F: '$4==gid {print $1}' gid=$gid /etc/passwd`
# list users who are recorded members of g
u2=`nawk -F: '$1==g {gsub(/,/," "); print $4}' g=$g /etc/group`
# remove duplicates from the union of the two lists
echo $u1 $u2 | tr " " "\012" | sort | uniq | tr "\012" " "
echo

Example: lhd and grpx

This example shows how the administrator can propagate a skeleton .profile file to the home directory for each member of a group. If the membership list of the clerk group changes, the code does not require modification.

$ for u in `grpx clerk` ; do
>     cp /etc/skel/.profile `lhd $u`
> done


Contents Index Home Previous Next