Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change the user name in linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to change the user name in linux, the article is very detailed, has a certain reference value, interested friends must read it!

Sometimes, for some reason, we may need to rename the user name. We can easily change the user name and the corresponding home directory and UID.

Modify user name

We use usermod to modify the user name. Its syntax is

$usermod-l new_username old_username

For example, suppose we have a user named dan who wants to rename it to susan, then execute the following command under the terminal:

$sudo usermod-l susan dan

This will only change the user name, while everything else, such as user groups, home directories, UID, etc., will remain the same.

Note:-you need to log out from the account to be renamed and kill all the processes of the user. To kill all the processes of the user, execute the following command

$sudo pkill-u dan$ sudo pkill-9-u dan

Modify the home directory

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 the groupmod command. Use the following command to modify the user group name

$groupmod-n susan dan

After you have made the changes, you can use the id command to check

The above $id susan is all about how to change the user name in linux. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report