• Feed RSS

Pages




Use the usermod command to modify a user's login account on the system.

The usermod Command Format and Options
The following is the command format for the usermod command :

usermod [ -u uid  [ -o ] ] [ -g gid ] [ -d dir ] [ -m ] [ -s shell ] [ -c comment ] [ -l newlogname ] loginname

in general,the options for the usermod command function the same as those for the useradd command.The following example changes the login name and home directory for chandra to gupta.


#usermod -m -d /export/home/gupta -l gupta chandra
Creating a User Account

Use the
useradd command to add new user accounts to the local system.These commands add an entry for a new user into the /etc/passwd and /etc/shadow files.
These commands also automatically copy all the initialization files from the /etc/skel directory to the user's new home directory.
The following is the command format for the useradd command :

useradd [ -u uid ][ -g gid ][ -d dir ][ -m ][ -s shell ][ -c comment ] loginname


  • -u uid ( set the UID number for the new user )
  • -g gid ( defines the new user's primary group )
  • -d dir ( defines the full path name for the user 's home directory )
  • -m ( creates the user's home directory if it does not already exist )
  • -s shell ( defines the full path name for the shell program of the user's login shell )
  • -c comment ( specifies any comment )
  • loginname ( defines the user's login name for the user account )

the following example uses the useradd command to create an account for a user named chandra.it assigns 101 as the UID number, adds the user to the group it ,creates a home directory in the /export/home/ directory,and set /bin/ksh as the login shell for the user account.

#useradd -u 101 -g it -d /export/home/chandra -m -s /bin/ksh -c "Regular Account" chandra
64 block
#


The useradd command generates a file called /var/sadm/defadduser that contains the default values.If the contents of this file are amended ,the new contents become the default values for the next time the useradd command is used.User account is also locked by default when added with useradd command.This can be verified by viewing the contents of the /etc/shadow file :

#grep 'chandra' /etc/shadow
chandra:*LK*12708::::::

By convention,a user's login name is also the user's home directory name.You use the passwd command to create a password for the new account.

#passwd chandra
New Password: 12345
Re-enter new Password: 12345
passwd: password successfully changed for chandra