+5 votes
558 views
in Linux/Unix by (242k points)
reopened
Change Username username Ubuntu 21.04, 20.04 | Terminal

1 Answer

+3 votes
by (1.6m points)
 
Best answer

How to change username in Ubuntu with terminal

The username in Linux is a fundamental part of each task since without a user it would be impossible to access the computer, be it a normal user, a user with administrative permissions or even the root user himself, hence the importance of the user in Linux . Having differentiated users when different people use the same computer is important to separate information, even if the same person uses the PC in different ways..

 

To have a well-managed team, having users configured correctly helps us to be able to use it effectively. In Ubuntu 20.04, 20.10 or Ubuntu 21.04 it is possible to change the username from the terminal and getFastAnswer will explain how to do it in a simple way using commands.

 

 

To stay up to date, remember to subscribe to our YouTube channel!   SUBSCRIBE

 

How to change username in Ubuntu with terminal

 

Step 1

First, we create the new user using the following syntax:
 sudo adduser "user" 
Step 2

When pressing Enter we enter the password to assign and some data that can be omitted with the Enter key:

 

 

 

image

 

Step 3

Once the user is created, we are going to add it to the sudo group with the following command:
 sudo adduser "user" sudo 

image

 

 

Step 4

Now we set the password of the root user with the following command:
 sudo paswd root 

image

 

 

Step 5

We reboot the Ubuntu system:

 

image

 

 

Step 6

In the login screen we can see the new user created:

 

image

 

 

Step 7

We log in with this new user:

 

image

 

 

Step 8

In the system we open the terminal and access as root:
 su root 
Step 9

Then we execute the following:
 usermod -l "new name" -d / home / "new path" -m "new name" 

image

 

 

Step 10

Now we execute the following:
 passwd -l root 

image

 

 

Step 11

Again we restart the system and this time we access with the original user:

 

image

 

 

Step 12

In the terminal we delete the created user:
 sudo deluser "user" 

image

 

 

Step 13

Now we delete your profile. This allows the new assigned name to be preserved.
 sudo rm -r / home / ”user” 

image

 

With these steps we can change the username in Ubuntu..

 


...