usermod

>Usage

The usermod command is used to modify user account settings, such as usernames, UIDs, or locking accounts. It's an administrative tool for updating user details.

Note: this command requires sudo privileges.

>Syntax

sudo usermod [option] username

>Options

-l

Change the username to a new username.

-L

Lock the user account, preventing login.

-U

Unlock the user account, restoring login ability.

-u

Change the user ID (UID).

-e

Set the account to expire on a specific date.

>Examples

Example 1:

Dots

-zsh

> sudo usermod -l newusername oldusername


Confirm changes with id newusername.

Example 2:

Dots

-zsh

> sudo usermod -L username


Verify with sudo grep username /etc/shadow.

Example 3:

Dots

-zsh

> sudo usermod -e 2024-12-31 username


Verify with sudo chage -l username.

>Quiz

Progress: Question ? out of ?

Quiz Questions

Page written by Gokhan YILMAZ