This brief tutorial shows students and new users steps to change one’s username when using Ubuntu.
Unlike Windows, you can’t be logged in to Ubuntu while changing your username or account name. You must log in as a different user with root permissions to be able to change an account name.
Many tutorials tell you to log in as the root user, then change the username of the account you want to replace.
Although logging in as root to change an account username will work, this post will show you a different method that should also work without logging in as root.
If you’re a student or new user looking for a Linux system, the easiest place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners and folks looking for easier Linux distribution to use.
Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.
To get started with changing your Ubuntu username, follow the steps below:
Restart in recovery mode
To change your username while not logged in, simply restart Ubuntu in recovery mode and go to the root prompt shell “Drop to root shell prompt“
To log in to recovery mode, immediately after powering it on, quickly press either the Shift or Escape key.
At the GRUB screen, choose “Advanced options for Ubuntu“
Then select Ubuntu recovery mode (usually the second line).
Next select root (Drop to root shell prompt)
In the root prompt, type these commands:
First remount the root:
mount -o remount,rw /
To change the username and home folder name. Replace the new name with the new username and the old name with the current username.
Display Name is the name that shows up on the login screen.
sudo -- usermod -c "Display Name" -l newname -d /home/newname -m oldname
Also, change the group name. The newgroup should be the same as your username and the old group should be the same as your current username.
sudo -- groupmod -n newgroup oldgroup
When you’re done, reboot.
That should do it. You’ll be prompted with the new username when you log in back in.
DO NOT DO THIS IF YOUR HOME DIRECTORY IS ENCRYPTED!!!!
This post showed you how to change your username when using Ubuntu. If you find any error above, please comment below.
You may also like the post below:
It works fine, thank you. It saved me a lot of time and hassle.