Modify Linux User Account

We can change the all login properties using usermod. We can change the name login account, we can lock the account, lock the login, change the group name, change home directory, UID etc.


usermod [options] LOGIN


To change the name of the user account

usermod -l new_name existing__login_name
usermod -l k2admin k2admin1

To lock the user account

usermod -L user_name
usermod -L k2admin

To unlock the user account.

usermod -U k2admin

Option Description
d new home directory for the user account
e set account expiration date to EXPIRE_DATE
f set password inactive after expiration to INACTIVE
g force use GROUP as new primary group
G new list of supplementary GROUPS
a append the user to the supplemental GROUPS mentioned by the -G option without removing him/her from other groups
l new value of the login name
l lock the user account
m move contents of the home directory to the new location
o allow using duplicate (non-unique) UID
p use encrypted password for the new password
s new login shell for the user account
u new UID for the user account
U unlock the user account
Z new SELinux user mapping for the user account
Powered by k2schools
Skip to toolbar