Change Username CentOS 7: Step-by-Step Guide

To change the username in CentOS 7, you can follow these steps:

  1. Login to the CentOS 7 system as the root user.
  2. Please use the following command to change the username:
usermod -l 新用户名 旧用户名

For example, to change the username from oldusername to newusername, you can execute the following command:

usermod -l newusername oldusername
  1. Next, execute the following command to change the main directory path of the user:
usermod -d /home/newusername -m newusername
  1. To change the group name of a user, you can execute the following command:
groupmod -n newgroupname oldgroupname
  1. Finally, verify if the modifications were successful by using the following command to check user information:
id newusername

This is how you can successfully change the username in CentOS 7.

bannerAds