VectorLinux

Please login or register.

Login with username, password and session length
Advanced search  

News:

Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

Author Topic: How to I add an existing user to existing group?  (Read 6330 times)

rhauff

  • Vectorite
  • ***
  • Posts: 105
How to I add an existing user to existing group?
« on: October 16, 2007, 11:50:52 am »

I'm trying to give my user access to the serial port, so I want to add the user to the tty group. 
I have tried (as root):
usermod -G tty roland
usermod -a -G tty roland
adduser roland tty

Now in etc/groups I see this line:
tty::5:roland

but still if I run $groups I get only:
roland sys adm disk lp floppy audio video cdrom games scanner users

Any ideas???
Logged

saulgoode

  • Vectorite
  • ***
  • Posts: 340
Re: How to I add an existing user to existing group?
« Reply #1 on: October 16, 2007, 01:41:40 pm »

It is necessary to log out and then back in for group changes to be recognized.
Logged
A complex system that works is invariably found to have evolved from a simple system that works.

rhauff

  • Vectorite
  • ***
  • Posts: 105
Re: How to I add an existing user to existing group?
« Reply #2 on: October 17, 2007, 08:29:24 am »

I forgot to mention, I had logged out after each attempt.  However, today after booting up again, it now shows tty in groups.  BUT....., now I only have:

roland tty floppy audio video cdrom

One of the commands must have screwed up my original groups!  That explains why I couldn't shutdown as regular user yesterday!  Good thing I posted my original groups on here, now at least I know which ones to add back.  After thinking about it, one of the commands worked to add my user to the tty group (after logging out & in), but the "groups" command must not have updated until I rebooted.

So, anyway, which was the proper command to add a user to a group without screwing up the existing groups?
« Last Edit: October 17, 2007, 08:45:23 am by rhauff »
Logged

rbistolfi

  • Packager
  • Vectorian
  • ****
  • Posts: 2301
Re: How to I add an existing user to existing group?
« Reply #3 on: October 17, 2007, 09:13:48 am »

the usermod command does not append, you need to put all the groups plus the new group, i.e., if the user is a member of a group which is not listed, will be removed from the group. Should be

usermod -G roland,sys,adm,disk,lp,floppy,audio,video,cdrom,games,scanner,users,tty roland

The list of groups must be separated by a comma with no spaces.
Logged
"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!

saulgoode

  • Vectorite
  • ***
  • Posts: 340
Re: How to I add an existing user to existing group?
« Reply #4 on: October 17, 2007, 09:22:44 am »

To add user 'rhauff' to the 'tty' group, you could use the following:

usermod -G $(groups rhauff | sed 's/ /,/g'),tty rhauff

Logged
A complex system that works is invariably found to have evolved from a simple system that works.

rhauff

  • Vectorite
  • ***
  • Posts: 105
Re: How to I add an existing user to existing group?
« Reply #5 on: October 17, 2007, 09:29:02 am »

Thanks very much.  It is working, I used usermod -G with the full list of groups.  It threw me off yesterday when I checked with the "groups" command and it didn't reflect the change.
Logged

rbistolfi

  • Packager
  • Vectorian
  • ****
  • Posts: 2301
Re: How to I add an existing user to existing group?
« Reply #6 on: October 17, 2007, 10:13:33 am »

To add user 'rhauff' to the 'tty' group, you could use the following:

usermod -G $(groups rhauff | sed 's/ /,/g'),tty rhauff


Very cool, thanks
Logged
"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!