Name

usermod [options] username — shadow-utils

Synopsis

/usr/sbin stdin stdout - file -- opt --help --version

The usermod command modifies the given user’s account in various ways, like changing a home directory:

# usermod -d /home/another smith

Useful options

-d dir

Change the user’s home directory to dir.

-l username

Change the user’s login name to username. Think carefully before doing this, in case anything on your system depends on the original name. And definitely don’t do it to system accounts (root, daemon, and so on)!

-s shell

Change the user’s login shell to shell.

-g group

Change the user’s initial (default) group to group, which can either be a numeric group ID or a group name, and which must already exist.

-G group1,group2,…

Make the user a member only of the additional, existing groups group1, group2, and so on. If the user previously belonged to other groups, but you don’t specify them here, the user will no longer belong to them.

-L

Disable the account so the user cannot log in.

-U

Unlock the account after a -L operation.

Get Linux Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.