This is how I change my login username for my Linux (Debian) machine.
First I log out to make sure no processes are running for that user, then I log in as root.
Then make sure no processes are still running as the olduser
ps aux | grep olduser
kill any process still running as olduser
before continue, renaming a user will fail if a process is still running.
Lets change the login name of the olduser
account to the new raddinox
login name
usermod -l raddinox olduser
and to change the olduser
group to raddinox
groupmod -n raddinox olduser
Now it is possible to login and use my new raddinox user, but the home folder is still /home/olduser
so to change that we need to rename the folder and change the home folder path for the user
First we change the user home folder path
usermod -d /home/raddinox raddinox
Now my new user has the /home/raddinox
path just like I want to, but this path does not exist. I want all my old settings so lets just rename our old home folder to the new one
mv /home/olduser /home/raddinox
Finally done and I can now use my new raddinox user.