usermod Essentials

Linux Logo

usermod Essentials

Also see Linux Users and Linux Groups

Linux Logo

Add User to a Group

sudo usermod -aG group1,group2,group3 username

Check Group Membership

groups username

Change Home Directory

Do not run this command as the user that owns the home folder login as root or an other user with root privileges. You will need to logout and back in for it to take effect.

sudo usermod -d /home/temphome username

Create a new home directory

sudo usermod -d /home/temphome --move-home username

Create a new home directory and move the old files into it

Change User Name

usermod -l newusername oldusername

Lock Out User

usermod -L username

Set Password Expiration

usermod -e username 2022-09-13

Check Password Policy

chage -l username