LinuxQuestions.org
Visit Jeremy's Blog.
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 04-26-2007, 02:02 AM   #1
SBN
Member
 
Registered: Jul 2006
Distribution: UBUNTU, CentOS, FEDORA 8
Posts: 474

Rep: Reputation: 30
Adding user to a group


- Hey guys how do you assign a user to a certain group using the terminal.
 
Old 04-26-2007, 02:29 AM   #2
deadeyes
Member
 
Registered: Aug 2006
Posts: 609

Rep: Reputation: 79
Quote:
Originally Posted by SBN
- Hey guys how do you assign a user to a certain group using the terminal.
"man useradd" tells you all posibilities.

usermod -a -G GROUP1[,GROUP2,...] username
 
Old 04-26-2007, 07:44 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
The subtlety here is that you do not add (assign) users to groups.
You add (assign) groups to users
 
Old 04-26-2007, 07:49 AM   #4
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 6,147

Rep: Reputation: Disabled
sudo vi /etc/group

 
Old 04-27-2007, 07:34 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by Emerson
sudo vi /etc/group

OK--so you are telling me that I can edit this file to add users to groups....touche

BUT!!!
I did a little experiment:
Presuming that the "groups" command gets its info from this file, I disabled my access and ran the groups command. It came back with the GIDs of all my groups, but complained that it could not get the names (because I disabled access to the group file)

So, where did the groups command find the GIDs?
And what would happen if I only edited /etc/group?
 
Old 04-27-2007, 07:58 AM   #6
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 6,147

Rep: Reputation: Disabled
All good questions.

Actually I do edit group file directly. Doing a fresh install I find it's the most convenient way. Just open one file and do it all at once, instead of running useradd multiple times. It works that way. Refreshing environment is required to validate changes. Logoff-login will do, too.
Don't know where GID's come from in your test, set in environment? You tell us.
 
Old 05-04-2007, 01:32 PM   #7
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 6,147

Rep: Reputation: Disabled
Quote:
So, where did the groups command find the GIDs?
You have nscd running. Stumbled across this one today, looking for something else.
 
Old 05-04-2007, 01:40 PM   #8
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 75
Personally I prefer using gpasswd to add users to groups e.g.
Code:
#gpasswd -a user group
 
Old 05-04-2007, 01:55 PM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by Emerson
You have nscd running. Stumbled across this one today, looking for something else.
Nope--nothing with ps -e, nothing in synaptic, no man page
 
Old 05-04-2007, 02:04 PM   #10
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 6,147

Rep: Reputation: Disabled
Don't know then.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
adding user to group ryancoolest Linux - Newbie 9 04-14-2008 12:50 PM
adding a user to a group ekdya Debian 5 09-16-2006 01:51 PM
Adding user to a group onjoo Linux - Newbie 1 03-05-2006 06:23 AM
after adding user to group peter72 Linux - General 2 08-01-2005 10:17 AM
adding user to a group Chilipepa Linux - Newbie 2 09-27-2003 11:08 AM

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

All times are GMT -5. The time now is 12:14 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration