Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004

    Unanswered: Remove the account and lock up the home directory ?

    hey all;

    I'm trying to delete a user from /etc/passwd.My little script should perfom the following
    *Display a list of usernames as listed in /etc/passwd who's user ID is 500 or greater.

    *Prompt for which user to remove

    *Remove the account and lock up the home directory

    awk '$3 => 500 {print $1} /etc/passwd
    echo "Enter here the user name that you want to delete please:" deluser
    var3='grep "$deluser" | cut -d":" -f3 /etc/passwd'
    read -n deluser
    userdel $deluser

    but I don't know how to lock up the home directory

  2. #2
    Join Date
    Jan 2004
    Bordeaux, France
    The operator for 'greater or equal' in awk is '>=' not '<='.
    The /etc/passwd file is ':' delimited, so you must specify this delimiter when you access it with awk :

    awk -F: '$2 >= 500 { print $1 }' /etc/passwd

    If a command that list users exists on you system (for example 'lsuser' on AIX), use it instead of reading the passwd file.

    Your var3 assignment will not work.
    You must use backward quote '`' or '$( )' construct.
    Your grep command haven't input file specified, so stdin will be used.

    var3=$(grep "^$deluser:" /etc/passwd | grep -d: -f3)
    var3=$(awk -F: '$1 == User {print $3}' User="=deluser" /etc/passwd)

    A solution for locking the home directory is to change its owner to root, and set acces to 400.
    You can also rename the home directory.

  3. #3
    Join Date
    Mar 2004
    thanks for the answer.It worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts