Hack 70. Create a new user

by Ramesh

Add a new user – Basic method

Specify only the user name.

  1. # useradd jsmith

Add a new user with additional Parameter

You can also specify the following parameter to the useradd

  • -c : Description about the user.
  • -e : expiry date of the user in mm/dd/yy format
  1. # adduser -c "John Smith - Oracle Developer" -e 12/31/09 jsmith

Verify that the user got added successfully.

  1. # grep jsmith /etc/passwd
  2. jsmith:x:510:510:John Smith - Oracle Developer:/home/jsmith:/bin/bash

Change the user password.

  1. # passwd jsmith
  2.  
  3. Changing password for user jsmith.
  4. New UNIX password:
  5. BAD PASSWORD: it is based on a dictionary word
  6. Retype new UNIX password:
  7. passwd: all authentication tokens updated successfully.

How to identify the default values used by useradd?

Following are the default values that will be used when an user is created.

  1. # useradd –D
  2.  
  3. GROUP=100
  4. HOME=/home
  5. INACTIVE=-1
  6. EXPIRE=
  7. SHELL=/bin/bash
  8. SKEL=/etc/skel