Datasheet

32
Phase 1
Working on the Command Line
passwd to begin the password-changing process and allow the users to type their own desired
passwords:
# passwd tbrown
New UNIX password:
Retype new UNIX password:
passwd: password updated successfully
You would type passwd tbrown, then let the user type a password (twice). The system
doesn’t echo the password for security reasons.
Alternatively, you can set the password yourself to some random value and find a way to com-
municate this value to the user. The trouble with this approach is that the communication could
be intercepted or copied, leading to an immediate security breach. Users might also leave their pass-
words set at the value you give them, which is non-optimal but might be acceptable if you choose
a unique and good password for each account. (Phase 7 describes passwords in more detail.)
Deleting User Accounts
You can delete an account with userdel, which works much like useradd:
# userdel sjones
This command deletes the sjones account. It does not, however, delete the user’s home
directory or mail spool, much less other files that may be owned by the user elsewhere on the
computer. You must manually delete or otherwise deal with these files.
Before deleting an account, back it up to tape, CD-R, or some other medium.
You can then give the backup to the user, if appropriate, or store it yourself in
case another user (such as this individual’s replacement in your organization)
needs the files.
You can pass the -r option to have userdel delete the user’s home directory and mail
spool. This option won’t delete other files the user may own elsewhere on the computer,
though. To locate those files, use find (described in Task 1.4) with its -uid n option to search
for files owned by UID n. If you search for files before deleting the account, you can use find’s
-user username option to search by username.
Modifying User Accounts
What if an account already exists and you want to change it in some way? You can modify the
account with usermod, which takes most of the same options as useradd. Another important
usermod option is -l name, which alters the username associated with the account. To change
the home directory of Dale Smith’s (dsmith’s) account from /home2/dsmith to /home/
dsmith, you’d type the following command:
# usermod -d /home/dsmith
83484.book Page 32 Monday, September 18, 2006 8:58 AM