It is common now to acquire linux appliances with a preconfigured user account which you simply set a password for. Sometimes it is helpful to change your username for better integration with your network environment for example “ssh firstname.lastname@example.org” may become “ssh 10.0.1.23”, and transferring documents which use absolute pathnames in links to your home directory may be easier to transfer to your new system.
The following simple procedure can be used to update your user account details. In this example I’m using a Parallels pre-built virtual machine with the username “parallels” which I want to make my own.
- If a GUI is running switch out of it using something like ctrl + alt + F2
- login as the user “parallels” with the set password
- Enable the root account which is likely disabled with: sudo passwd root #then enter a root password
- Logout, then login as “root” with the password you’ve set
- Change the username with: usermod -l andrewread parallels
- Move the home directory with: usermod -d /home/andrewread -m andrewread
- You can verify this with: ls /home #to see the new home folder
- Change the full name with: chfn -f “Andrew Read” andrewread
- Depending on how the system is setup your user may have their own primary group, to update this do something like: groupmod -n andrewread parallels
You might want to disable the “root” account now and do all further system administration with the “sudo” command. This is optional:
- Logout of root then login with your new username which in this example is “andrewread”
- Clear the root password with: sudo passwd -d root #and enter your user account password when prompted
- Disable the “root” account with sudo usermod -L root
That’s all you need to do!