How to change username on Ubuntu, Debian, Linux Mint or Fedora
This is a step-by-step guide on how to change your username on Debian, Ubuntu, Linux Mint (and other Debian / Ubuntu-based Linux distributions) and Fedora.
These instructions explain how to change (rename) the user name and the user’s home folder name, and a simple workaround for potential problems with the profile that still points to the old home folder name. There is also a step to change the full name (display name), which appears on the login screen and elsewhere on the entire desktop.
In all the instructions / commands below, remember to replace it newusername
Use a new username, and oldusername
Use old username 1. Create a temporary user and give it sudo permissions.
We will log in as a temporary user to execute the username change command. This way, there is no problem running them on the same user we are trying to rename (for example, processes that are running for that user, etc.).
Add a new temporary user (tempuser
) And grant sudo privileges on Debian, Ubuntu or Linux Mint (After entering the password, you can continue to press Enter
Skip entering the rest of the information):
sudo adduser tempuser
sudo usermod -aG sudo tempuser
Add one tempuser
And grant sudo privileges on Fedora:
sudo adduser tempuser
sudo passwd tempuser
sudo usermod -aG wheel tempuser
2. Login tempuser
And change (rename) the username, home folder and group.
Log out and select on the login screen tempuser
And log in with that user. Next, open a terminal and run the following command to change your username, home folder and group oldusername
to newusername
:
sudo usermod -l newusername -d /home/newusername -m oldusername
sudo groupmod -n newusername oldusername
If you find an error about a process that the old username is using, terminate the process (kill PID
), But this should not be the case in most cases, as we log in with a temporary intermediate username to make these changes. If it does happen, another workaround is to restart and log in directly tempuser
So that the old username will not use any processes. 3. Create a symbolic link from /home/newusername
to /home/oldusername
.
Some applications display errors when changing usernames, because in some cases, some configuration files point to the home folder of the old username. One solution is to create a symbolic link from the new home folder to the old home folder:
sudo ln -s /home/newusername /home/oldusername
4. Change the display name / full name (first name last name).
In my case, trying to rename the username on Ubuntu 19.04 and Fedora 29, the display name (full name) remained the same on the GDM3 login screen and the user menu. You can change this setting using:
sudo chfn -f "firstname lastname" newusername
Replace firstname
with lastname
Your first and last name, or what you want to appear on the login screen and various other places throughout the system. firstname
with lastname
It can also be an item, such as your new username.
of chfn
The command on Fedora util-linux-user
Software package, not installed by default. You can install it on Fedora using:
sudo dnf install util-linux-user
After installing this package, chfn
The command should run on Fedora.5. Log in with the new (renamed) username, and delete the temporary user created in step 1.
Log out and select the new renamed username from the login screen, and then continue to log in. You can now delete the temporary user created in step 1 (tempuser
) And its home folder:
sudo userdel -r tempuser