Linux: Managing Groups


  • With the groupadd command, you can create new groups.
  • When you add a group to the system, the system places the group's name in the /etc/group file and gives it a group ID number. If shadow security is in place, then changes are made to the /etc/gshadow file.
  • The groupadd command only creates the group category. Users are individually added to the group.
  • In the next example, the groupadd command creates the artists group.

  • Example: groupadd artists

  • The file /etc/group consists of group records, with one record per line and its fields separated by colons.
  • A group record has four fields: a group name, a password, its ID, and the users who are part of this group. The Password field can be left blank.

Here is an example of an entry in an /etc/group file.

  • The group is called artists, there is no password, the group ID is 101, and the users who are part of this group are vish, raj, suvarni, krithi and gokul.
  • artists::101:vish,raj,suvarni,krithi,gokul
  • As in the case of the /etc/passwd file, you can edit the /etc/group file directly using a text editor, unless you have implemented shadow security.
  • Instead of using either Linuxconf or groupdel, you could simply delete the entry for that group in the /etc/group file.
  • This can be risky, however, if you make accidental changes.
  • If you have implemented shadow security measures, then group entries are kept in an encrypted /etc/gshadow file.
  • You cannot edit this file. Changes can only be made through a utility like groupmod.
  • To do so manually, create a directory for the group in the /home directory and change its group to that of the group, along with allowing access by any member of the group.
  • The following example creates a directory called muroor and changes its group to that of the muroor group:

Example: mkdir /home/muroor

Example: chgrp muroor /home/muroor

The read, write, and execute permissions for the group level should be set:

Example: chmod g+rwx /home/muroor

  • Any member of the muroor group can now access the /home/muroor directory and any shared files placed in the directory.
  • This directory becomes a shared directory for the group muroor now. You can, in fact, use the same procedure to make other shared directories at any location on the file system.

Linux: Managing Users << Previous
Next>> Linux: Summary of some user and group related commands

Our aim is to provide information to the knowledge seekers. 

comments powered by Disqus