Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to modify user name in Linux system

Shulou Source: shulou.com Published: 2022-06-01 14:37:05 09月12日 Update

This article mainly explains "how to modify the user name in Linux system". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian slowly and deeply to study and learn "how to modify the user name in Linux system" together!

modify the username

We use usermod to modify user names. Its syntax is,

$ usermod -l new_username old_username

As an example, suppose we have a user named dan who wants to rename himself susan, then execute the following command on the terminal:

$ sudo usermod -l susan dan

This only changes the username, while everything else, such as user groups, home directories, UID, etc., stays the same.

Note: -You need to log out of the account you want to rename and kill all processes of that user. To kill all processes of that user, execute the following command

$ sudo pkill -u dan$ sudo pkill -9 -u dan Modify Home

To change the home directory at the same time, we need to add the-d option to the usermod command,

$ sudo usermod -d /home/susan -m susan Change User UID

Execute the following command to modify the User UID

$ sudo usermod -u 2000 susan

Here 2000 is the user's new UID.

Modify user group name

To change the user group name from dan to susan, we need to use groupmod. Use the following command to modify the user group name,

$ groupmod -n susan dan

After making the changes, you can use the id command to check that

$ id susan Thank you for reading, the above is the "Linux system how to modify the user name" content, after the study of this article, I believe that everyone on the Linux system how to modify the user name this problem has a deeper experience, the specific use of the situation also needs to be verified. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Tags: Users user names commands systems user groups directories learning content and at the same time processes things examples ideas situations articles more knowledge points articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL Redmi Shulou Tech Info Huawei