LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-26-2009, 06:25 PM   #1
[KIA]aze
Member
 
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Rep: Reputation: 16
Is it possible to add/remove a user to a group without logging out and in again?


Is it possible to add/remove a user to a group without logging out and in again?

i.e: Make changes to /etc/group effective without logging out and in again?
 
Old 02-26-2009, 06:26 PM   #2
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,523
Blog Entries: 3

Rep: Reputation: 439Reputation: 439Reputation: 439Reputation: 439Reputation: 439
yes
yes
 
Old 02-27-2009, 03:03 AM   #3
[KIA]aze
Member
 
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Original Poster
Rep: Reputation: 16
Thanks for answering, but could you please tell me how?
 
Old 02-27-2009, 04:16 AM   #4
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,523
Blog Entries: 3

Rep: Reputation: 439Reputation: 439Reputation: 439Reputation: 439Reputation: 439
google gives you this If you say hay I am not using slackware sorry it is all linux. sence you are using debian then just use admin . or open a terminal and do as slackware says.
these question can be found in a quick Google search. please search first I volunteer my time I am not paid.

Last edited by Drakeo; 02-27-2009 at 04:17 AM.
 
Old 02-27-2009, 05:29 AM   #5
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by Drakeo View Post
google gives you this
Dude! This link doesn't answer poster's question. Also when you send someone to google it is highly recommended to send them into right direction AND give them good keywords. Sending people to google without directions or keywords and giving them links that doesn't help is wasting their time.

Quote:
Originally Posted by Drakeo View Post
I am not paid.
Then don't reply if you are not going to give useful info. Everyone is volunteer here.

Last edited by ErV; 02-27-2009 at 05:34 AM.
 
Old 02-27-2009, 06:18 AM   #6
mrclisdue
Senior Member
 
Registered: Dec 2005
Distribution: Slackware -current, 14.2
Posts: 1,089

Rep: Reputation: 197Reputation: 197
To add or remove a user from a group, edit /etc/group file.

For the changes to take effect without logout, as root

/etc/rc.d/rc.messagebus restart

Karma is my pay.

cheers,
 
1 members found this post helpful.
Old 02-27-2009, 02:22 PM   #7
[KIA]aze
Member
 
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Original Poster
Rep: Reputation: 16
I don't have /etc/rc.d/rc.messagebus. I'm currently running Ubuntu 8.10.

Code:
[29][~]$  /etc/rc.d/rc.messagebus restart
bash: /etc/rc.d/rc.messagebus: No such file or directory
I tried "/etc/init.d/dbus restart" instead hoping it would be the equivalent Debian command, but it didn't work either.

Here's the output from dbus restart:
Code:
[26][~]$  sudo /etc/init.d/dbus restart
 * Stopping System Tools Backends system-tools-backends                  [ OK ] 
 * Stopping power management daemon powersaved                           [ OK ] 
landscape-client is not configured, please run landscape-config.
 * Stopping Hardware abstraction layer hald                              [ OK ] 
 * Stopping DHCP D-Bus daemon dhcdbd                                     [ OK ] 
 * Stopping Avahi mDNS/DNS-SD Daemon avahi-daemon                        [ OK ] 
 * Stopping system message bus dbus                                      [ OK ] 
 * Starting system message bus dbus                                      [ OK ] 
 * Starting Avahi mDNS/DNS-SD Daemon avahi-daemon                        [ OK ] 
 * Starting DHCP D-Bus daemon dhcdbd                                     [ OK ] 
 * Starting Hardware abstraction layer hald                              [ OK ] 
landscape-client is not configured, please run landscape-config.
 * Starting power management daemon powersaved                                  FATAL: Error inserting speedstep_centrino (/lib/modules/2.6.27-9-generic/kernel/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.ko): No such device
                                                                         [ OK ]
 * Starting System Tools Backends system-tools-backends                  [ OK ]
(I have a pentium 4, but I have no idea why it tries to load a centrino module, but this probably has nothing to do with the group changes...)

edit:
I also tried the "sg" and "su" commands, but they also don't achieve what I want.
With "su USER", I can create a new session and the group changes are effective.
With "sg GROUP", I can log in with a given GID, which just gives me that group's permissions no matter whether I belong to it or not.

I want the group changes to be effective in the session I am currently in.

Last edited by [KIA]aze; 02-27-2009 at 02:47 PM.
 
Old 02-27-2009, 04:11 PM   #8
lumak
Member
 
Registered: Aug 2008
Location: Phoenix
Distribution: Arch
Posts: 799
Blog Entries: 32

Rep: Reputation: 111Reputation: 111
try to grep for the information in the /etc folder...


Code:
grep -R messagebus /etc/*
 
Old 02-27-2009, 04:17 PM   #9
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
newgrp -
 
Old 02-27-2009, 05:31 PM   #10
[KIA]aze
Member
 
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by AlucardZero View Post
newgrp -
Didn't work.

Code:
[72][~]$  sudo grep -R messagebus /etc/*
grep: /etc/alternatives/vi.pl.1.gz: No such file or directory
grep: /etc/alternatives/mmencode: No such file or directory
grep: /etc/alternatives/firefox-homepage-locales/images: No such file or directory
grep: /etc/alternatives/firefox-homepage-locales/kubuntu.css: No such file or directory
grep: /etc/alternatives/ex.pl.1.gz: No such file or directory
grep: /etc/alternatives/view.it.1.gz: No such file or directory
grep: /etc/alternatives/view.ru.1.gz: No such file or directory
grep: /etc/alternatives/movemail: No such file or directory
grep: /etc/alternatives/ex.ru.1.gz: No such file or directory
grep: /etc/alternatives/view.pl.1.gz: No such file or directory
grep: /etc/alternatives/vi.it.1.gz: No such file or directory
grep: /etc/alternatives/gdm-config-derivative: No such file or directory
grep: /etc/alternatives/fakeroot.sv.1.gz: No such file or directory
grep: /etc/alternatives/ex.it.1.gz: No such file or directory
grep: /etc/alternatives/vi.ru.1.gz: No such file or directory
grep: /etc/alternatives/firefox-homepage: No such file or directory
grep: /etc/alternatives/irc.protocol: No such file or directory
grep: /etc/alternatives/faked.sv.1.gz: No such file or directory
/etc/dbus-1/system.conf:  <user>messagebus</user>
grep: /etc/gdm/gdm-cdd.conf: No such file or directory
/etc/group:messagebus:x:109:
/etc/group~:messagebus:x:109:
/etc/group-:messagebus:x:109:
/etc/group.20080502:messagebus:x:109:
/etc/gshadow:messagebus:!::
/etc/gshadow-:messagebus:!::
/etc/init.d/dbus:DAEMONUSER=messagebus
/etc/passwd:messagebus:x:103:109::/var/run/dbus:/bin/false
/etc/passwd-:messagebus:x:103:109::/var/run/dbus:/bin/false
/etc/rc1.d/K88dbus:DAEMONUSER=messagebus
/etc/rc2.d/S12dbus:DAEMONUSER=messagebus
/etc/rc3.d/S12dbus:DAEMONUSER=messagebus
/etc/rc4.d/S12dbus:DAEMONUSER=messagebus
/etc/rc5.d/S12dbus:DAEMONUSER=messagebus
/etc/shadow:messagebus:!:13801:0:99999:7:::
/etc/shadow-:messagebus:!:13801:0:99999:7:::
grep: /etc/ssl/certs/Verisign_Class_1_Public_Primary_OCSP_Responder.pem: No such file or directory
grep: /etc/ssl/certs/SPI_CA_2006-cacert.pem: No such file or directory
grep: /etc/ssl/certs/Verisign_Secure_Server_OCSP_Responder.pem: No such file or directory
grep: /etc/ssl/certs/Verisign_Class_3_Public_Primary_OCSP_Responder.pem: No such file or directory
grep: /etc/ssl/certs/Verisign_Class_2_Public_Primary_OCSP_Responder.pem: No such file or directory
grep: /etc/ssl/certs/spi-ca.pem: No such file or directory
 
Old 02-27-2009, 08:14 PM   #11
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Code:
NAME
       newgrp - log in to a new group

SYNOPSIS
       newgrp [-] [group]

DESCRIPTION
       The newgrp command is used to change the current group ID during a login session. If the
       optional - flag is given, the userīs environment will be reinitialized as though the user
       had logged in, otherwise the current environment, including current working directory,
       remains unchanged.


       newgrp changes the current real group ID to the named group, or to the default group
       listed in /etc/passwd if no group name is given.  newgrp also tries to add the group to
       the user groupset.
Did you add the user to the group?
 
Old 03-01-2009, 01:52 PM   #12
[KIA]aze
Member
 
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Original Poster
Rep: Reputation: 16
Quote:
Did you add the user to the group?
Yes, I did.

Code:
[1][~]$  ll ./test.txt
-rw-rwx--- 1 root group1 14 2009-02-27 21:23 ./test.txt
[2][~]$  grep group1 /etc/group
group1:x:1011:KIAaze
[3][~]$  cat ./test.txt
cat: ./test.txt: Permission denied
[4][~]$  newgrp -
xset:  unable to open display ""
[1][~]$  cat ./test.txt
cat: ./test.txt: Permission denied
[2][~]$
If I just run "newgrp -" as a normal user, I get xset: 'unable to open display ""', but it logs me into something which looks like a new sessions, but I still don't have the permissions I should have.

If I run "newgrp - group1", it asks me for a password which doesn't seem to be the root password or the user password.

If I run it as root or with sudo, it gives me a new session as root where I obviously have all permissions.

Just to be clear:
I want a way to allow use of certain programs to certain users for given time windows.
That's why I first thought of setting those programs to certain groups and then adding/removing selected users to/from those groups. (using chmod affects all users)
The problem is that this currently requires logging out and in to take effect.
 
Old 03-01-2009, 05:49 PM   #13
lumak
Member
 
Registered: Aug 2008
Location: Phoenix
Distribution: Arch
Posts: 799
Blog Entries: 32

Rep: Reputation: 111Reputation: 111
sudo /usr/sbin/usermod -G $(groups | tr " " ","),newgrpname yourusername

after that, temporarily for any terminal, you can use "newgrp newgrpname" and have access to that group. Your window manager has to be restarted to use it in your window manager. I have not seen anything that says other wise. SO... if you don't use a graphical log in, and you log in through the console, you can do what you want without 'logging out' but it appears you are stuck with restarting xwindows no matter what. I could be wrong... I don't see the big deal with logging out and back in.

restarting dbus on my system did not solve this. I still had to shut down x, newgrp, then startx. If you think of all the time wasted on trying to figure this out, you could have been in your new group already with all your programs started back up. How often do you have to add new groups anyway?
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to list user in Linux box, add an user to a group! steady_lfcfan Linux - Newbie 12 01-27-2013 01:14 PM
How to remove user from their secondary group? Akhran Linux - Newbie 2 09-13-2006 04:09 AM
how to add a user to a new group? emanresu Linux - Newbie 5 11-21-2005 08:18 AM
add user to group brandnewbie Linux - Newbie 3 08-08-2004 04:53 PM
how can i add a user to a group? doublefailure Linux - General 14 07-10-2002 11:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:48 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration