8

I'm using fedora19, and I've added wheel to my account like this.

usermod -a -G wheel ironsand

And I've logged out and logged in again to take effect the command according to the following answer. https://ask.fedoraproject.org/question/9769/sofia-is-not-in-the-sudoers-file/

I don't need to restart when I change .bashrc, if I use source command. Is there no way to take usermod effect likewise?

marked as duplicate by Thomas Nyman, terdon, slm, jasonwryan, Joseph R. Oct 16 '13 at 22:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You don't need to log out to login. Running su <username> is sufficient. – Marco Oct 16 '13 at 17:31
6

Careful where you draw your analogies. The sourcing of the .bashrc can be dangerous in the sense that if a variable is being added to you'll get into the situation where something like this can occur:

initial env

PATH=/path/to/dir

sourced env

PATH=/path/to/dir:/path/to/dir

That's why it's generally a good practice to logout and log back in when fundamental changes are made to low level environment files such as .bashrc and/or .bash_profile.

Being added to or removed from Unix groups should also be viewed as a major change, requiring a logout/login.

You can get some access, at least in a single shell, by also doing one of these 3 operations with respect to the Unix group changing showing up:

  • su - <user>
  • su <user>
  • newgrp

The 3rd method will work, but it will require you to blindly change your self to a group that doesn't show up yet in your existing environment, and will then make your primary group this new group, which may not be what you want.

Why

If you take a look at the man page, credentials you'll see why child processes cannot have changes made via usermod immediately reflected in a real-time way:

excerpt

A child process created by fork(2) inherits copies of its parent's user and groups IDs. During an execve(2), a process's real user and group ID and supplementary group IDs are preserved; the effective and saved set IDs may be changed, as described in execve(2).

Not the answer you're looking for? Browse other questions tagged or ask your own question.