Debian

How to Change Username on Debian 11 Bullseye

When you set up the Debian system on your device, the first thing you have to enter is the username. But later on, you might not like the username and want to change it. Each user in Debian has a specific unique username that identifies them. If you want to change your current username in Debian, you can change it anytime by following this article’s guidelines.

Change Username on Debian 11 Bullseye via Command Line

Note that you cannot change the username of a current user on Debian. However, you can change the current username by creating a temporary user and then login to that user and changing it accordingly.

For example, if you have a username with “user1” id, you will need to create another user “user2”, and login to that user on the system. After that, you can change the username of user1.

To create a new user on Debian, follow the below-given command:

sudo adduser mainuser

After creating the user, give this user sudo privileges from the following command:

sudo usermod -aG sudo mainuser

Now, verify the user by displaying the list of all the users. The following command in the Linux is used to get the list of all users:

cut -d: -f1 /etc/passwd

Change Username on Debian 11 Bullseye

You can change username on Debian 11 from:

1: Change Username on Debian from Terminal

There are two ways to change the username on Debian from the terminal:

i: Change Username on Debian from Terminal Using usermod Command

First, make sure the username has not logged in to the system. Change the name using the usermod command. The name of the user will be changed from the old name to the new name:

sudo usermod -l <newname> <oldname>

In the below-given example I am changing the username of my temporarily created user with the name of mainuser to the zainab:

sudo usermod -l zainab mainuser

Verify whether the name is changed or not by executing the command for displaying the list of users:

ii: Change Username on Debian from Terminal Using sed Command

Open the terminal and switch to the root via the following command:

sudo su

Then change the username of the account by entering the old and new name. The following is the basic syntax of the command:

sed -i s/<old_user>/<new_user>/g /etc/passwd

Let’s change the username zainab to the linux2 by the following command:

sed -i s/zainab/linux2/g /etc/passwd

Once you run the command, reboot the system and you will see the changed name on the lock screen:

Change Username on Debian 11 Bullseye via GUI

The other easiest approach to changing the username on the Debian is via the GUI. Launch the settings of the device from Activities:

In the device settings, click on the Users from the left panel and you will see the list of users on the right side of the screen. You have to enter the password first to make the changes in the device:

In the below image, I am modifying the username of Linux2 to zainab by clicking on the pencil icon:

The username has been changed successfully:

Wrap Up

Errors can be encountered while setting a username for your Debian system but you can fix them. In Debian, you can use the usermod command to change the current username. To change the username in Debian first you need to create a temporary user with sudo privileges so that the username of the current user can be altered. Hopefully, you’ve now got the username for your Debian system just the way you like it.

About the author

Zainab Rehman

I'm an author by profession. My interest in the internet world motivates me to write for Linux Hint and I'm here to share my knowledge with others.