Rename existing user oldname to newname.
Which command is appropriate?
usermod -l NEW_LOGIN OLD_LOGIN changes an existing login name. The home-directory name does not change automatically.
Detailed explanation
usermod -d newname oldnameIncorrect. -d changes the home-directory path.
usermod -g newname oldnameIncorrect. -g changes the primary group.
usermod -l newname oldnameCorrect. It changes oldname to newname.
usermod -s newname oldnameIncorrect. -s changes the login shell.
Try it yourself
An example you can run in a temporary verification environment.
usermod --help | grep -E -- '-l,|--login'Expected result
新しいログイン名を示す説明行Key points
- -l means login name
- It changes an existing user
- Home path needs separate handling
Notes
- Environment: shadow-utils usermod help / 状態変更なし
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Account record
Identity attributes such as a user ID, home directory, and login shell.
Group membership
Primary and supplementary groups used during permission checks.
Password aging
State and time limits that control password changes and account access.