[lug] newgrp and aliases
Davide Del Vento
davide.del.vento at gmail.com
Wed Jan 16 13:51:19 MST 2013
Folks,
I want to change my default group on a Linux machine. I can't do it in
/etc/passwd because that file gets generated automatically by a smart
system which does not understand my needs and can't be changed (at
least not in the very near future).
Now I know that I can do it interactively with newgrp but that is
inconvenient to remember to do at each login, so I thought to include
it into my .bash_profile
However that's proving harder than I thought, for the following reasons:
1) if I put newgrp at the beginning of .bash_profile the rest of the
file is not executed (basically it stops executing bash profile and it
spawn a new shell - if finishes executing bash profile when
exiting....)
2) if I put newgrp (without the "-" argument) at the end of
.bash_profile my aliases got lost in the spawning (and I still have to
exit twice)
3) if I put newgrp (with the "-" argument) at the end of .bash_profile
it enters into an infinite loop, spawning new shells forever (not too
bad, CTRL-C stops the loop and it ends in a status I like, but now I
have to "exit" several times to logout)
So far the most convenient thing seems 3 (with a sleep to throttle
it), but that seems really ugly and could go awry if I get distracted
right before CTRL-C'ing and leave the infinite loop on the machine....
Is there a better approach to solve this dilemma?
Thanks
Davide
More information about the LUG
mailing list