How do I create create a new Linux User account ??

Posted: October 2, 2012 in Terminal Masters
Tags: , , , , , , , , , , , , , , ,

How do I create create a new Linux user account ?

What are command line options for adding a user?

To create a new user account under any Linux distribution use the command called “useradd” .  The system administrator is responsible for creating account. Login as root user (or use sudo command).

useradd Command Syntax

# useradd [options] {username}

Depending on command line options, the useradd command will update system files (/etc/passwd and /etc/shadow file with password) and may also create the new user’s home directory and copy initial files.

Linux add a New user “test”

Type the command as follows:

#useradd test
Setting a password for test:

#passwd test
Without password user account will be in locked status. To unlock the account, you need to use above passwd command. Use passwd command to assign a password.

Set account disable date

You can set date for the account to be disabled in the format YYYY-MM-DD with -e option while creating account itself:
#useradd -e {yyyy-mm-dd} {username}
#useradd -e 2008-12-31 test

Set default password expiry

The -f {days} option set number of days after the password expires until the account is disabled. (If 0 is specified, the account is disabled immediately after the password expires. If -1 is specified, the account is not be disabled after the password expires.)
useradd -f {days} {username}
useradd -e 2009-12-31 -f 30 test


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s