19.2 Managing Groups

   

As mentioned earlier, every user belongs to one or more groups. A group contains users who are related to each other in one way or another. Information about groups is kept in the /etc/group file. There is one entry for each group in this file. Every group has a group name and a group ID. The file also contains a list of users who are members of more than one group (users who are members of a single group are not listed in this file). Like users, groups can also be added or deleted using command-line utilities as well as SAM.

Standard Groups

There are many standard groups on HP-UX. Some of these are:

  • bin

  • sys

  • adm

  • daemon

  • mail

  • lp

  • users

Each of these groups is used for a special purpose. For example, files and processes related to printing fall under the lp group. The default group for general users is users , mail files belong to the mail group, and so on.

Creating, Deleting and Modifying Groups

A group can be created using the groupadd command. To create a group for accounts, use a command like the following.

 groupadd accounts 

You can also specify a group ID (GID) on the command line using the -g option. If you don't specify a group ID, the next available one is used for the new group.

A group can be deleted with the help of the groupdel command. A group name is provided as the argument to the command as follows .

 groupdel accounts 

The groupmod command is used to modify a group name or group ID. To change the name of the accounts group to acct use this command.

 groupmod -n acct accounts 

Multiple Group Membership

A user can be a member of multiple groups. The group ID of the primary group is stored in the /etc/passwd file with the user's record. For all secondary groups, the user name is listed in the /etc/group file in the respective group line. A user can use the id or groups command to list the current group membership. Watch the output of the id command used by the root user.

 #  id  uid=0(root), gid=3(sys) groups=0(root),1(other),2(bin),4(adm),5(daemon),6(mail), 7(lp),20(users) # 

This command shows user and group IDs for the root user. The user ID is 0 and the default or primary group ID is 3. The primary group name is sys . The user root is a member of other groups as listed after the groups keyword. Each group is listed as a pair of group ID and group name.

The groups command lists the names of the groups the user is a member of. Output of this command for the root user is shown here.

 #  groups  sys root other bin adm daemon mail lp users # 

When you create a new file, its group membership is that of your current group. To change your group membership temporarily, use the newgrp command. To change the group of root user temporarily to bin , use the following command.

 newgrp bin 

After that, when you use the id command, the output will be as follows.

 #  id  uid=0(root), gid=2(bin) groups=0(root),1(other),3(sys),4(adm),5(daemon),6(mail), 7(lp),20(users) # 

   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net