Q. How do I change user name (rename user name) or UID under Linux operating system?
A. Use the usermod command to change user name under Linux. it modifies the system account files to reflect the changes that are specified on the command line.
Syntax is as follows
usermod -l login-name old-name
Where,
=> The name of the user will be changed from old-name to login_name. Nothing else is changed. In particular, the user's home directory name should probably be changed to
reflect the new login name.
usermod -u UID username
Where,
=> The numerical value of the user's ID (UID) . This value must be unique, unless the -o option is used. The value must be non-negative. Values between 0 and 99 are typically reserved for system accounts. Any files which the user owns and which are located in the directory tree rooted at the user's home directory will have the file user ID changed automatically. Files outside of the user's home directory must be altered
manually.
Task: Change username from tom to jerry
Type usermod command as follows:
# id tom
# usermod -l jerry tom
# id jerry
# id tom
Task: Change user tom UID from 5001 to 10000
Type usermod command as follows
# id tom
# usermod -u 10000 tom
# id tom
Read man page of usermod for more information.
本文介绍了如何在Linux系统中更改用户名和用户ID,包括使用usermod命令进行操作的详细步骤,并强调了在更改用户ID后手动修改由该用户创建的目录/文件所有者的必要性。

1875

被折叠的 条评论
为什么被折叠?



