Howto: Create a New User Account in Linux (w/ Usage)

Creating or adding a user in Linux can be done using the useradd 命令. The user created via useradd command stays locked until it is assigned a password.

To add a user in any Linux distro, run the following command (adding user called ‘account-name’):

useradd account-name

EXAMPLE: Adding user called ‘Sayyam’:

useradd sayyam

Setting password for user ‘Sayyam’.

passwd sayyam

The user unlocks after setting the password.

密码 & Account Expiry

Linux also has one great feature, 那是, it can automatically disable an account and expire account password based on date.

The format for adding an expiry date for a user is:

useradd -e {yyyy-mm-dd} {account-name}


useradd -e 2013-11-19 sweeno

Format for setting password expiry date:

useradd -e {yyyy-mm-dd} -f {days} {account-name}

-e option: Used to specify password expiry date.

-f option: Used to set number of days after the password expires until the user account is disabled. If -f is set to 30, account is disabled 30 days after password expiry. If -f is set to 0, account is disabled immediately after password expiry. If -f is set to -1, account is not disabled after password expiry.


useradd -e 2013-07-05 -f 20 easter

The account is disabled 20 days after July 5.