- How to Change Username in Ubuntu Linux
- Restart in recovery mode
- Change username
- He, Peng
- Change the Username and Hostname on Ubuntu
- Change the username
- Change the hostname, which is the computer name
- Change the password
- Back-propagation in Neural Network, Octave Code
- Linux Essentials
- How To Change Username On Ubuntu, Debian, Linux Mint Or Fedora
- How do I change my username?
- 8 Answers 8
- Change Username in Ubuntu
- Changing the username in Ubuntu
- 1. Change username in Ubuntu
- 2. Change the Group name in Ubuntu
- 3. Change the name of the home directory
- What happens to files owned by the old username?
How to Change Username in Ubuntu Linux
This brief tutorial shows students and new users steps to change one’s username when using Ubuntu.
Unlike Windows, you can’t log into 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 account username 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 most accessible place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners and folks looking for easier distribution.
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:
Change username
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 new group should be the same as your username, and the old group should be your current one.
sudo -- groupmod -n newgroup oldgroup
That should do it. You’ll be prompted with the new username when you log 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:
Richard W
I love computers; maybe way too much. What I learned I try to share at geekrewind.com.
He, Peng
Robotic is the integration of all human knowledge, so far.
Change the Username and Hostname on Ubuntu
Abstract: If you didn’t give a perfect user name and host name(the computer name), you can change them later.
Change the username
At the start screen press Ctrl+Alt+F1 .
Log in using your username and password.
Set a password for the «root» account.
Log in using the «root» account and the password you have previously set.
Change the username and the home folder to the new name that you want.
Change the group name to the new name that you want. I’m not so sure about which group should I change to
If you were using ecryptfs (encrypted home directory). Mount your encrypted directory using ecryptfs-recover-private and edit /.ecryptfs/Private.mnt to reflect your new home directory.
Log out.
Change the hostname, which is the computer name
Type the following command to edit /etc/hostname using nano or vi text editor:
Delete the old name and setup new name.
Next Edit the /etc/hosts file:
Replace any occurrence of the existing computer name with your new one.
Reboot the system to changes take effect:
Change the password
Back-propagation in Neural Network, Octave Code
Abstract: This post is targeting those people who have a basic idea of what neural network is but st…
Linux Essentials
Tilix, A Good Terminal You Need This terminal offers all the morden things that you need: 1. Split…
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 Linux distributions based on Debian/Ubuntu), and Fedora.
The instructions explain how to change (rename) the username along with the user’s home folder name, as well as a simple work-around for potential issues with configuration files that still point to the old home folder name. There’s also a step for changing the full name (display name), which is shown on the login screen and other places throughout the desktop.
Throughout all the instructions / commands below, remember to replace newusername with the new username, and oldusername with the . old username.
1. Create a temporary user and give it sudo privileges.
We’ll login with the temporary user to perform the username change commands. This way there won’t be any issues running them from the same user we’re trying to rename (e.g. processes running for that user, etc.).
Add a new temporary user ( tempuser ) and give it sudo privileges on Debian, Ubuntu or Linux Mint (after entering a password you can keep pressing Enter to skip entering the rest of information):
sudo adduser tempuser sudo usermod -aG sudo tempuser
Add a new tempuser and give it sudo privileges on Fedora:
sudo adduser tempuser sudo passwd tempuser sudo usermod -aG wheel tempuser
2. Login with tempuser and change (rename) the username, home folder and group.
Logout, and on the login screen select tempuser and login with that user. Next, open a terminal and run these command to change your username, home folder, and group from oldusername to newusername :
sudo usermod -l newusername -d /home/newusername -m oldusername sudo groupmod -n newusername oldusername
If you get an error about a process being in use for the old username, kill that process ( kill PID ), but that shouldn’t happen in most cases since we’re logged in using a temporary, intermediate username to make these changes. If it does happen, another workaround is to reboot and then login straight with tempuser , that way there aren’t any processes used by the old username.
3. Create a symbolic link from /home/newusername to /home/oldusername .
Some applications will show errors when changing the username, because in some cases there are configuration files that point to the old username’s home folder. A solution for this 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 (firstname lastname).
In my case, trying to rename a username on Ubuntu 19.04 and Fedora 29, the display name (full name) remained unchanged on the GDM3 login screen and on the user menu. This can be changed though, using:
sudo chfn -f "firstname lastname" newusername
Replace firstname and lastname with your first and last name, or whatever you want to show up on the login screen and various other places throughout the system. firstname and lastname can also be one item, e.g. your new username.
The chfn command is available on Fedora in the util-linux-user package, which is not installed by default. You can install it on Fedora using:
sudo dnf install util-linux-user
After installing this package, the chfn command should work on Fedora.
5. Login using the new (renamed) username, and delete the temporary user created on step 1.
Logout and select the new, renamed username from the login screen, and proceed to login. You can now delete the temporary user created in step 1 ( tempuser ) and its home folder:
How do I change my username?
Some time ago, when I installed Ubuntu, I chose a rather stupid username for my account that I do not want to use anymore. How do I change this (including the name of my home directory, and the name in the terminal) without losing settings for applications?
How do I keep permissions and my keys for various authentification (e.g. email, SSH, GPG and more)?
What settings could possibly get lost if I changed my username?
Why can’t we navigate to /usr/share/applications/users.desktop >> Click on the user for which the name has to be changed. >> Click on Change User name >> Change the name >> Click on Ok. I think, this would be the easiest way to change the username, wouldn’t it?
8 Answers 8
Unix-like operating systems decouple the user name from the user identity, so you may safely change the name without affecting the ID. All permissions, files, etc are tied to your identity (uid), not your username.
To manage every aspect of the user database, you use the usermod tool.
To change username and user’s groupname (it is probably best to do this without being logged in):
sudo usermod -l newUsername oldUsername sudo groupmod -n newUsername oldUsername
This however, doesn’t rename the home folder.
sudo usermod -d /home/newHomeDir -m newUsername
after you changed the username.
For instance, you could logout, drop to a console ( Ctrl + Alt + F1 ), and sudo su — to become true root (as opposed to sudo -s , where $HOME is still /home/yourname.) Maybe you also have to kill some still running processes from this user first. To do so, enter ps -u username , look for the matching PID and kill them by kill PID-number .
Update: as arrange mentioned, some files may reference your old home directory. You can either keep a symlink for backward compatibility, e g ln -s /home/newname /home/oldname or you can change the file contents with sed -i.bak ‘s/*oldname*/*newname*/g’ *list of files* It creates a backup for each file with a .bak extension.
Some additional information for not so experienced users like me:
As I only have ONE user account (administrator), it would not let me change the username («you are already logged in» was the response in TTY1 ( Ctrl + Alt + F1 ). To get around this:
- Login with your old credentials and add a new user, e.g. «temporary» in TTY1:
set the password. 2. Allow the temporary user to run sudo by adding the user to sudo group:
sudo adduser temporary sudo
- Log out with the command exit .
- Return to tty1: Login with the ‘temporary’ user account and password. Change your username and folder as mentioned above. exit (until you get the login prompt)
- Go back to TTY7 ( Ctrl + Alt + F7 ) to login on the GUI/normal desktop screen and see if this works.
- Delete temporary user and folder:
sudo deluser temporary sudo rm -r /home/temporary
Change Username in Ubuntu
Misspelled the name while creating a user? Don’t worry; you can change the username in Ubuntu quite easily and effortlessly.
As the root user or with sudo, you can use the usermod command to modify a user account to change its name.
usermod -l new_username old_username
As you can see, it is pretty straightforward. Still, let me show it in detail with actual examples. I’ll also discuss renaming the home directory to make the username change complete.
Changing the username in Ubuntu
You need to switch to the root account or use sudo with an admin user account to change the username.
Make sure that the user you are trying to rename is logged out. Otherwise, it won’t let you change the username. Needless to say, you cannot change the name of the user you are logged in as even with sudo.
To change your username completely, I’m going to divide this process into three simple steps.
1. Change username in Ubuntu
To change the username, all you have to do is execute the following command:
usermod -l newUsername oldUsername
Here, I will be changing from sagar to abhiman :
2. Change the Group name in Ubuntu
In Ubuntu, every user has a default group with the same name as the user. To follow this norm, I suggest changing the group name as well.
To change the group name, follow the given command syntax:
groupmod -n newUsername oldUsername
For me, I’m changing the group name from sagar to abhiman :
3. Change the name of the home directory
Technically, not changing the name of the home directory won’t cause any issues. But to make it a seamless experience, you should go for it.
You can use the same user modification command usermod like this:
usermod -d new_home_directory -m new_username
With the -m option, it copies the contents of the current home directory (/home/old_username) to the new home directory.
As I’m changing to abhiman , my command looks like this:
usermod -d /home/abhiman -m abhiman
Now log out and log back in with the new username and it should work as expected:
And if you followed the steps correctly, you would have the same effect.
What happens to files owned by the old username?
You don’t need to change the ownership of the files anywhere. Linux works on an ID system. Users are assigned UID and groups have GID. When you change the username, the ID is not changed and hence, files owned by the user (UID) are also not changed.
In other words, the changed user name still owns the file created by the old username.
I hope you will find this guide helpful and if you have any queries or suggestions, let me know in the comments.