Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
usermod -g change PRIMARY group so the group ID (GID) is specified in /etc/passwd for the user rather than in /etc/group. If you don't want to change PRIMARY but rather add to ADDITIONAL groups you'd use usermod -G instead. It will then leave the GID in /etc/passwd unmodified and show the user in /etc/group associated with the group you selected.
But groups after -G have just replaced previous groups but only primary group has remained (and NEW additional secondary groups). How to ADD new groups to the list.
The following is the quote from the Beginning Ubuntu LTS Server Administration From Novice to Professional, Second Edition by Sander van Vugt:
When working with group ownership, you should be aware of how group ownership is handled.
By default, the primary group of the user who creates a new file becomes the group
owner of that file. If, however, the user is a member of more than one group, this default setting
can be manipulated. When a user issues the newgrp command, he can change the primary
group setting on a temporary basis. The following steps show what happens next:
1. Log in as some normal user on your computer. Then use the groups command from a
console window to get an overview of all groups that you are currently a member of.
The primary group is listed first. If you haven’t modified anything for this user, it will
have the same name as your user account. Listing 5-4 is an example of this output.
sander adm dialout cdrom floppy audio dip video plugdev scanner lpadmin admin
2. From the console window, issue the touch newfile command to create a new file
with the name newfile. Then use ls -l newfile to display the ownership information
for newfile. You will see that the primary group is set as the owner of the file (see
3. Use su to become root. Then use groupadd to create a new group (for example, use
groupadd -g 901 sales to create a group with the name sales and group ID 901). Next,
as root, use usermod -g 901 youruser to make youruser (the user you used in step 1) a
member of that group. After changing this group information, use exit to close the su
session and become the normal user account again.
4. As the normal user, use groups again to get an overview of all groups you are currently
a member of. The new group should appear now, probably as the last group in the list.
5. As the normal user, use newgrp yournewgroup to set the primary group to your new
group on a temporary basis. You can use the groups command to check this; the new
group should now be listed first. You’ll also see that if you create a new file (use touch
somenewfile), the new group will be group owner of the new file. This ensures that all
users who are members of the same group can do the same thing to this file."
If you're asking how you can put new groups in /etc/group you do that with the groupadd command.
groupadd -g <GID> <groupname>
groupadd -g 700 oracle
Would add group named "oracle" with GID of 700.
You could then use the useradd -G oracle <username> to add the user you want to the group.
From the usermod man page on CentOS 5:
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
A list of supplementary groups which the user is also a member of.
Each group is separated from the next by a comma, with no intervening whitespace. The groups are subject to the same restrictions as the group given with the -g option. If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via -a option, which appends user to the current supplementary group list.
Notice the sentence I bolded.
You can usually get lots more information about any UNIX/Linux command by typing "man <command>" where command is the one you're interested in e.g. man groupadd
Last edited by MensaWater; 11-30-2009 at 09:16 AM.
Thank you jlightner. But I just did steps from the book (see please my previous edited post, if it doesn't bother you). So what is your opinion about that quotation? I agree with you regarding man pages.