Home > Article > System Tutorial > How to rename linux
There are six steps required to change the user name in the Linux system: create a new user with corresponding permissions; set the new user's password; copy the existing user files to the new user's home directory; transfer the group permissions to the new user ;Exit the old user session and log in with the new username to authenticate; Delete the old user (optional).
How to change the username in the Linux system
In the Linux system, the username is the only way to identify the user identifier. You may need to change your username for security or other reasons. This article will guide you through the process.
Steps:
1. Create a new user
First, you need to create a new user with the appropriate permissions. Use the following command:
<code>sudo adduser 新用户名</code>
where replace "new username" with the username you want to create.
2. Set Password
Next, set a password for the new user:
<code>sudo passwd 新用户名</code>
Enter and confirm the new password.
3. Copy user files
Now you need to copy the existing user files to the new user’s home directory:
<code>sudo cp -r /home/旧用户名 /home/新用户名</code>
Where, Replace "old username" with your old username.
4. Transfer group permissions to the new user
Transfer the ownership of the old user group to the new user:
<code>sudo chown -R 新用户名:新用户名组 /home/新用户名</code>
Where, "New User Group name" with the new user's group name.
5. Verify new user
Exit the old user session and log in with the new username and password. Verify that all required files and settings are accessible.
6. Delete the old user (optional)
You can delete the old user if you no longer need it:
<code>sudo deluser 旧用户名</code>
Tip:
The above is the detailed content of How to rename linux. For more information, please follow other related articles on the PHP Chinese website!