LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Adding user but not thier grp (https://www.linuxquestions.org/questions/linux-newbie-8/adding-user-but-not-thier-grp-916975/)

ochieman2000 12-03-2011 07:25 PM

Adding user but not thier grp
 
Hello all,

I have "adduser -G emails $userinput" in a perl script but I would like to specify what group they are added to. With this command they are added to emails BUT I dont want them to get their own grp.

example being if I add user josh then it creates a group josh.

I would also as a bonus like to know how to get rid of the orphaned group josh. I added him as a test for the script then did a userdel josh but now group josh is vacant and wont let me delete as it is the "primary group for Josh"...

=) Thanks

TB0ne 12-03-2011 07:44 PM

Quote:

Originally Posted by ochieman2000 (Post 4541325)
Hello all,

I have "adduser -G emails $userinput" in a perl script but I would like to specify what group they are added to. With this command they are added to emails BUT I dont want them to get their own grp.

example being if I add user josh then it creates a group josh.

You don't say what version/distro of Linux, but most folks user "useradd" to do it. The "-G" is for adding a user to additional groups, other than the main. The "-g" is where you specify the GID of the users primary group. So, look in the /etc/group file for the GID number of the emails group, and use it as the "-g" qualifier.
Quote:

I would also as a bonus like to know how to get rid of the orphaned group josh. I added him as a test for the script then did a userdel josh but now group josh is vacant and wont let me delete as it is the "primary group for Josh"...

=) Thanks
In this case, you'll have to do a "usermod -g <GID number> josh", and move the josh user to a new primary group. Then delete the group with the groupdel command. Man pages are there for all these commands, and will point you to other similar commands (most of the time).

Andrew Benton 12-03-2011 08:32 PM

The command to add a user is useradd, to add a group, groupadd, to delete a user, userdel and to delete a group, groupdel. To find out more about how to use them, read
Code:

man useradd

ochieman2000 12-09-2011 01:11 PM

Quote:

Originally Posted by Andrew Benton (Post 4541361)
The command to add a user is useradd, to add a group, groupadd, to delete a user, userdel and to delete a group, groupdel. To find out more about how to use them, read
Code:

man useradd

Such a waste of a response. Why do you even bother. I had a PERL issue not a useradd. I also mixed up the -G and -g that I got from reading the man useradd. Don't be such a tool and post "man useradd"

Also check out this post

http://www.linuxquestions.org/questi...62#post4541362

Look at what Chirel said....maybe take a tip from him on how to assist people with minor learning moments.

TB0ne 12-09-2011 02:26 PM

Quote:

Originally Posted by ochieman2000 (Post 4546088)
Such a waste of a response. Why do you even bother. I had a PERL issue not a useradd. I also mixed up the -G and -g that I got from reading the man useradd. Don't be such a tool and post "man useradd"

Also check out this post

http://www.linuxquestions.org/questi...62#post4541362

Look at what Chirel said....maybe take a tip from him on how to assist people with minor learning moments.

I certainly tried to help you here, too.

EDDY1 12-09-2011 03:39 PM

Quote:

example being if I add user josh then it creates a group josh.
Yes you are correct in this example, but while user josh has his own group, if you add josh to another group, when he accesses the other group files they will belong to the other group, but if josh has newly created items for his group then they are only accessible by josh unless others are added to his group.
Tbones post is quite informative you may want to study it as it looks like it can help you a great deal.


All times are GMT -5. The time now is 08:21 PM.