LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices


Reply
  Search this Thread
Old 12-03-2011, 07:25 PM   #1
ochieman2000
LQ Newbie
 
Registered: Oct 2011
Posts: 15

Rep: Reputation: Disabled
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
 
Old 12-03-2011, 07:44 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,685

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by ochieman2000 View Post
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).
 
Old 12-03-2011, 08:32 PM   #3
Andrew Benton
Senior Member
 
Registered: Aug 2003
Location: Birkenhead/Britain
Distribution: Linux From Scratch
Posts: 2,073

Rep: Reputation: 64
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
 
Old 12-09-2011, 01:11 PM   #4
ochieman2000
LQ Newbie
 
Registered: Oct 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Andrew Benton View Post
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.

Last edited by ochieman2000; 12-09-2011 at 01:13 PM.
 
Old 12-09-2011, 02:26 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,685

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by ochieman2000 View Post
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.
 
Old 12-09-2011, 03:39 PM   #6
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
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.

Last edited by EDDY1; 12-09-2011 at 03:43 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Adding a new user to Solaris 9 so that this user can ssh into the server rcforster Solaris / OpenSolaris 2 03-14-2011 06:10 AM
how to check which grp a user belong to? binary_0011 Linux - Newbie 3 09-18-2006 05:12 AM
Gentoo GRP mirrors? orange400 Linux - Distributions 1 05-03-2006 02:15 AM
using GRP on gentoo cmario00 Linux - General 1 01-21-2005 03:37 PM
Tracking Users and thier commands Shai Linux - Security 1 08-13-2001 06:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration