To change the users home directory, execute the following:
usermod -l <newname> -d /home/<newname> -m <oldname>
And to change the group of the user, execute the following.
groupmod -n <newgroup> <oldgroup>
Just make sure you are logged in as a different user before executing the same. You can either login as root user or create an other user with sudo privileges to execute the commands.
I guess the “groupmod -n ” will require that you are logged in with the user which you are changing; however below you say “make sure you are logged in as a different user”. Aren’t you going to change the group of the “different user” that way?
As far as I know the changing of group and getting rid of others can be done with the following two commands one after another:
# usermod -g
# usermod -G
Alternatively if you want to keep all existing groups as secondary you can use the “-a” flag and directly issue only this command:
# usermod -a -G
This will preserve all existing groups and change the primarily group only.
I guess the “groupmod -n ” will require that you are logged in with the user which you are changing; however below you say “make sure you are logged in as a different user”. Aren’t you going to change the group of the “different user” that way?
As far as I know the changing of group and getting rid of others can be done with the following two commands one after another:
# usermod -g <newgroup> <user>
# usermod -G <newgroup> <user>
Alternatively if you want to keep all existing groups as secondary you can use the “-a” flag and directly issue only this command:
# usermod -a -G <newgroup> <user>
This will preserve all existing groups and change the primarily group only.