If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Remove the account and lock up the home directory ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-04-04, 00:01
iamagirl iamagirl is offline
Registered User
 
Join Date: Mar 2004
Posts: 10
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
Reply With Quote
  #2 (permalink)  
Old 04-04-04, 06:01
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
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.
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 04-04-04, 10:03
iamagirl iamagirl is offline
Registered User
 
Join Date: Mar 2004
Posts: 10
thanks for the answer.It worked
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On