In a term (let's say a PuTTY session), I want to see my current shell bash replacing by a fresh new one, while refreshing the user's groups (among others).

I know that exec bash --login replace current shell by a new one, reloading .bashrc or .profile files, but it does not reloading /etc/groups. I suppose this command doesn't load all system configuration file (more details on that will be appreciated).

I know that su - username do, but it creates another nested shell, not replacing the current one (and it ask for password). I don't want to type any password, nor have to exit one more.

Is there a way to natively achieve this? => Replacing my current shell with a new one, in the exact same way as I log in in another term (s fresh session with reloading bash file, groups, and so.

  • 1
    This question should be on superuser website. Sorry for the incovenience. – 4wk_ Mar 27 '17 at 12:43

I guess you are looking for the newgrp command. You don't need to start a new shell, just:

newgrp GROUP

Of course you need to have added to that group by the system administrator before.

  • I still want to get another new fresh shell, in order to load the conf file too. I suppose I could do exec bash --login then newgrp GROUP but what if there is others envirnnement's file not used with the exec bash? I really want the same behaviour as I log in another time. – 4wk_ Mar 27 '17 at 9:27
  • You may try exec sudo login -f YOUR_USER. Does that work for you? – hek2mgl Mar 27 '17 at 9:47
  • Hm. It asks my password for sudo. But it did replace the current shell, and reloading everything. That's close :/ EDIT : I'm not sure the exec is usefull, I have the same behaviour without. – 4wk_ Mar 27 '17 at 12:39
  • 1
    When you don't use exec you can type exit and will return back to the previous shell. That's why you use exec – hek2mgl Mar 27 '17 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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