[ Pobierz całość w formacie PDF ]
.In the end, it is a lot of tedious work,especially if you need to add more than a few users!Luckily, nowadays UNIX tools manage most of this tedium.Some tools do abetter job than others.Which one you use for your administration will dependon your choice and on the number of users that you need to manage.Some ofthe tools, such as useradd, are mediocre, whereas some, such as adduser,are fantastic!The useradd and adduser tools are installed in the /usr/sbin directory.Your shell should be able to see these programs if you are logged in as root.Managing user accounts is a privileged role for the superuser.Previous Table of Contents NextProducts | Contact Us | About Us | Privacy | Ad Info | HomeUse of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.All rights reserved.Reproduction whole or in part in any form or medium without express written permission of EarthWeb isprohibited.http://www.itknowledge.com/reference/standard/078971826x/ch18/205-209.html (3 of 3) [1/27/2000 5:51:20 PM]Complete Idiot's Guide to Linux:Users, Groups, and PasswordsTo access the contents, click the chapter and section titles.Complete Idiot's Guide to Linux(Publisher: Macmillan Computer Publishing)Author(s): Manuel RicartGo!ISBN: 078971826xPublication Date: 12/22/98KeywordBrief FullAdvancedSearch this book:SearchSearch TipsGo!Previous Table of Contents Next-----------Adding UsersSo you need to add a user.What do you do? Your choices are to use adduser anduseradd.adduseradduser is a command line tool for adding user accounts.It is interesting because itmanages both /etc/passwd and /etc/group to implement User Private Groups (UPGs;see Chapter 16), a strategy in which each user is made a member of a group that only he orshe belongs to.Using UPGs simplifies the process of sharing files between users, and for thisreason alone, adduser should be the program you use for adding accounts to your system.Ifyou installed OpenLinux using the standard install option as you were instructed, addusershould already be on your system.If it is not, you can install it from your CD.To add a new user, just type adduser username, like this:[root@digital alberto]# adduser flowerLooking for first available UID.502Looking for first available GID.502Adding login: flower.done.Creating home directory: /home/flower.done.Creating mailbox: /var/spool/mail/flower.done.Don t forget to set the password.This command swiftly found the next available UID and GID and created entries for them inhttp://www.itknowledge.com/reference/standard/078971826x/ch18/209-212.html (1 of 4) [1/27/2000 5:51:21 PM]Complete Idiot's Guide to Linux:Users, Groups, and Passwords/etc/passwd and /etc/group.It created the home directory /home/flower, copiedall the startup files from /etc/skel, and then created a mailbox.Although this is the bulk of the work, optional details about the user, such as the user s realname, were not set.To set those details, you can use the chfn command.See the section Changing Your Personal Information: chfn in Chapter 17, Command Toolbox: UsefulShell Commands and Shortcuts.A more important detail that is not set by default is the account password.To set a passwordfor the account, see the section Changing Your Password: passwd in Chapter 17.Something to keep in mind when adding users is that the username should be kept at eight orfewer characters.Longer usernames are not handled properly by the system and/or otherprograms.UseraddUseradd is similar to adduser; the only problem is that it doesn t manage the groupsdatabase, nor does it implement the UPG scheme, which can simplify much of what you do inthe long run.To add an account through useradd, just type the following:useradd -m usernameThe -m option creates the home directory.The password for the account still must be set, asmust the real name for the user and other user information.Modifying Users: usermodAs time goes by, some users will need certain changes made to their accounts.The easy wayto make changes is to use usermod, because it offers various options that you can set.Moving a Home DirectoryTo move a home directory, use this syntax:usermod -d newdirpath -m login[root@digital root]# usermod -d /home/newflower -m flowerThis option modifies the location of the home directory specified by the /etc/passwd fileto point to the directory specified by the -d option.It also creates the home directory if itdoesn t exist.The -m option moves the contents from the old home directory into the newone.If you are changing the name of the home directory, you ll probably also want to change thelogin name for the user.This option only changes the home directory name; the login nameremains as it was.Changing a Login NameTo change a login name, type the following:usermod -l newlogin currentlogin[root@digital root]# usermod -l newflower flowerhttp://www.itknowledge.com/reference/standard/078971826x/ch18/209-212.html (2 of 4) [1/27/2000 5:51:21 PM]Complete Idiot's Guide to Linux:Users, Groups, and PasswordsThis option changes the login name for the user.All other information remains the same.Typically, when you change a login name, you ll also want to change or move a homedirectory, as explained in the preceding section.In the example shown here, the login nameflower is changed to newflower.Changing Secondary Group MembershipsTo change secondary group memberships, type this:usermod -d newdirpath -m loginusermod -d /home/newflower -m flower[root@digital root]# groups flowerflower : flower users[root@digital root]# usermod -G wheel,database flower[root@digital root]# groups flowerflower : flower wheel databaseThe groups command prints a list of all the current group affiliations for a user
[ Pobierz całość w formacie PDF ]