Useradd Command Assignment Help

Assignment Help: >> User and Group Management - Useradd Command

The useradd command

The useradd command utility is used to create a user account.

Syntax

Useradd          - [Options] hostname: username

Note:  Other flavors of UNIX use something same; frequently, it is adduser. The individual have to login as root to add users to UNIX workstations.

Useradd has a specific syntax and various options which might or might not be useful. Most frequently, a tool to add new user account works with default files that are commonly stored in the /etc directory. Within some flavors, these default files may be stored elsewhere.

The default files are known as /etc/login.defs. This file determines how the computer adds user accounts. It describes the following things:

  • Range of the acceptable user ID and group ID numbers
  • Whether or not a user's password or account expires and if so, whenever and where the user's mail will be reserved
  • Whether and where the computer will make a home directory for new users; the minimum acceptable length for user passwords.
  • Whether or not the system will erase all processes which are owned through a deleted user

The  default  files  holds  information about  disk  space  quotas,  standard  home  directory  structures and password aging needs, and etc. If values for these are not specified when creating a new user then the system will use the default values stored in these files.

The options which apply to this command are

-u         user-id

It is a numerical id for the user and should be unique. The range of values which are utilized for creating user-ids will begin from 500. The upper limit of the range is based on the respective flavors.

Note: The values in between 0 to 499 are kept for system accounts in linux.

-g group-id

It specifies a numerical id for the group that already exists. The range of values which are utilized for the creation of group-id begin from 500 The upper limit based on their particular flavors. By default the group id will be 1 when no value is specified for the group.

-G secondary group-id

G secondary group-id is used to add a user in secondary groups belong to provided, the similar user belong to the primary group.

Note: The user might be permitted to belong to 16 secondary groups.

-c         comment

This identifies a text string of not more than 512 characters. The string must not contain colons (:) or new lines.

-d         home directory

This specifies the new home directory of the user. The contents of the previous home directory are modified only if -m is specified or if the home directory is being changed. Directory names have not contained colons (:).

-m        -k skeleton directory

If it does not exist the user's home directory will be created. The files holds in skeleton_dir will be copied to the home directory if the -k option is used, else the files holds in /etc/skel will be used. Several directories holds in skeleton_dir or /etc/skel will be created in the user's home directory as well.  In -k option is only valid in conjunction with the -m option.  The default is not to copy any files and not to make the directory.

- s default shell

This will specifies the name of the user's login shell.  The default is to leave this field blank that causes the system to select the default login shell. -s shell is possible to modify the shell although creating the user through providing this option with either /bin/ksh or /bin/csh.

Note: The default shell is Bourne shell (/etc/sh) and in the case of LINUX. A default shell is Bourne again shell (/bin/bash) that is derived from Bourne shell.

-e [expire-date]

This denotes the date on that the user accounts will be disabled.  The date is specified in the format of YYYY-MM-DD.

Note: It is only available in the LINUX.

-f         [Inactive time period]

This denotes the number of days for that the account will remain inactive after a password expires until the account is permanently disabled.  The value of zero disables the account as soon as the password and a value of 1 disable these characteristics. So the default value is -1.

Note: It is only available in LINUX.

-r

This flag is used to make a system account.  The value of UID_MIN defined in /etc/login.defs if the user with an UID lowers. Useradd will not create a home directory for such a user, anyway of the default setting in /etc/login.defs. -m option must be specified to have a home directory to create a system account.

Note: It is only available in LINUX.

username

A user name has a limit of 8 lowercase letters or numbers, but must not begin with a number. Further, user names cannot involve colons (:) (Besides the hostname: A user syntax used to make a remote account) or new lines.

For distributed accounts, only the comment, user name, login shell, password, home directory, group membership, login group, password and lock status are valid across the network. For instance, the maximum number of failed login attempts cannot be set for a distributed user on a remote system (it only takes effect on the master server).

Associated Files to be updated whenever the useradd command is used are

  • /etc/passwd - the user account information
  • /etc/shadow - this secure user account information
  • /etc/group - group information
  • /etc/default/useradd - this is show default information
  • /etc/login.defs - system-huge settings
  • /etc/skel - directory containing default files

To Add a User

# useradd -u 501 -g 501 -G 502,503,504,505 -c "demo for adding new user"

-d /home/demo1 -m -s /bin/sh            -e 2001-03-01 -f 5 -r demo1

Practice 

# useradd - u 525 -g 515 -d /home/sudha -m -s / bin/sh sudha

# useradd - u 526 -g 516 -d /home/raja -m -s / bin/sh raja

# useradd - u 527 -g 517 -d /home/ravi -m -s / bin/sh ravi

# useradd -  u 528 -g 528 -d /home/ragu -m -s / bin/sh -e 25-09-2001 ragu

# useradd - u 529 -g 529 -d /home/ramesh -m -s / bin/sh ramesh

# useradd - u 530 -g 520 -d /home/dummy1 -m -s / bin/sh dummy1

# useradd - u 531 -g 521 -d /home/dummy2 -m -s / bin/sh dummy2

# useradd - u 532 -g 522 -d /home/dummy2 -m -s / bin/sh dummy2

set password for ragu, sudha, ravi, , raja,  ramesh, dummy1, dummy2, dummy3The above command will create users ragu, sudha, ravi, raja, ramesh, dummy1, dummy2, dummy3 with individual users ids and group ids. At last you have to create password for all the above users. Only For user ragu we are assigning expiry date.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd