Changing Username in Linux
·1 min
Table of Contents
Before you begin! #
You should login as another user or become root
To create a new user
sudo usermod -aG sudo <other_user>
Let’s get started! #
Change the username
sudo usermod -l <new_name> <old_name>
Change the groups <old_name>
to new username
sudo groupmod -n <new_name> <old_name>
Confirm this by looking into old home directory of <old_name>
ls -ld /home/<old_name>
- The owner and group owner should now be owned by
<new_name>
Change username for home directory #
Your home directory still may have previous name, here’s the fix…
sudo usermod -d /home/<new_name> -m <new_name>
Check to confirm
ls -ld /home/<new_name>
Edit username in GDM login screen #
When you log back in, you may still have previous name, here’s the fix…
sudo usermod -c "<new_name>" <new_name>
That’s it!