Linux Add user and user group commands to use tutorial

Source: Internet
Author: User
Tags command line reserved unique id

Useradd

Useradd [-C comment] [-D Home_dir]

[-E Expire_date] [F Inactive_time]

[G Initial_group] [G group[,...]]

[m [-K Skeleton_dir] |-m] [-s Shell]

[-U uid [-O]] [-N] [-R] Login

useradd-d [G Default_group] [-B default_home]

[F Default_inactive] [-E Default_expire_date]

[-S Default_shell]

New Account Establishment

When the-D argument is not added, the useradd instruction uses the command column to specify the set value of the new account and use the system

The new user account will generate some system files, user directory creation, handcuffs

Prepare the starting file, etc., which can be specified by using the command-column option. This version is for Red Hat Linux

To create individual group for each newly added user without adding the-n option. Useradd

The options you can use are

-C Comment

New Account password file description bar.

-D Home_dir

The Home_dir used by the new account each time it is logged in. The default value is default_home login name

, and as a login directory name.

-E Expire_date

Account expiration date. The specified format for the date is mm/dd/yy.

-F Inactive_days

The account expires several days after the permanent stop right. When the account is 0 o'clock, the right is immediately stopped. and the duty is

-1 To turn off this feature, the default is-1

-G Initial_group

Group name or number as the user login starting group (group). The group name shall be

The name of an existing existence. Group numbers are also required for existing groups. Preset number of groups

The word is 1.

-G group,[...]

Defines this user as a member of a heap of groups. Each group uses the "," area to

Cannot be mixed with blank characters.

The group name is limited to the-G option. Defines the starting group that the value is the consumer.

-M consumer directories are automatically created if they do not exist. such as using the-K option Skeleton_dir files within

will be copied to the consumer directory. However, the files in the/etc/skel directory will be copied.

Replace. Any directory in the Skeleton_dir Or/etc/skel is also the same in the consumer directory

One establishes. The-k with-M does not create a directory and does not copy any files as preset values.

-M does not establish a user directory, even if the/etc/login.defs system file is set to create the user directory

-N Default consumer group is the same as the user name. This option cancels this preset value.

-r This parameter is used to establish the system account number. The UID of the system account is more than defined on the system file.

/etc/login.defs. The uid_min come in small. Note that the account established by Useradd this usage is not

will create a user directory and will not care about the value of the record in/etc/login.defs. If

You want the user directory to have an extra-m parameter specified to establish the system account. This is red HAT.

Additional options are added.

-S Shell

The shell name to use when the consumer is logged in. The default is not to fill out, so the system will help you point to

Set the default login shell.

The ID value of the-u UID consumer. Must be a unique ID value, unless the-o option is used. Number is not negative

Value. The default is to be a minimum of less than 999 and successive additions. 0~999 is traditionally reserved for systems.

Account usage.

Change the preset value

When the-D option appears, Useradd shows the current preset, or updates it by command column

The preset value. The available options are:

-B Default_home

Defines the previous directory of the directory to which the consumer belongs. The user name is appended to the Default_home

The directory used later to create the new user. This option is not valid, of course, with-D.

-E Default_expire_date

User account stop date.

-F Default_inactive

The account expiration several days later stop right.

-G Default_group

New account start group name or ID. The group name must be the name of an existing existence. Group I d must also

is the existing group.

-S Default_shell

The shell name to use when the consumer is logged in. This shell will be used by the newly added account number in the future.

If you do not specify any parameters, Useradd displays the current preset values.

Notes

The System Manager is obligated to place the user-defined file in the/etc/skel directory.

This version of "Useradd" is modified by Red Hat.

Warning

New users are not available in NIS groups. You must perform on the NIS server.

File

/etc/passwd-User account information

/etc/shadow-User account information encryption

/etc/group-Group Information

/etc/default/useradd-definition Information

Generalized setting of/etc/login.defs-system

/etc/skel-contains a directory of defined files

Cases:

The code is as follows:

[Root@blackghost ~] Useradd tank #添加用户

[Root@blackghost ~] Useradd-r zhangy #添加系统用户

[Root@blackghost ~] useradd-d/home/zhangying zhangying #添加用户, and specified, home directory

[Root@blackghost ~] useradd-g mytest-d/home/hao hao #添加用户, specify the group, and set the home directory

[Root@blackghost ~] useradd-e 04/05/13 fxxk #添加用户 and set the expiration date for the user

Groupadd

Groupadd-set up a new group

Groupadd[-ggid[-o]][-r][-f]group[[]]

Groupadd can specify a group name to create a new group account. New group values can be obtained from the system when needed. Groupadd has the following options available.

-G GID ID value. The value must be unique, not identical, unless you use the-o parameter. The value cannot be negative. The default is to be a minimum of less than 500 and successive additions. 0~499 is traditionally reserved for system account use.

-r This parameter is used to establish the system account number. It will automatically help you select a GID less than 499 unless the command line plus the-g argument. This is the additional option for Red Hat.

-F This is the force sign. When a new existing group account is added, the system will receive an error message and end the Groupadd. If this is the case, it will not change the group (or add a new one) can also be combined with the-G option when you add a GID, then the GID is not a unique value, but without the-o parameter, the group will show results. This is the additional option for Red Hat.

File

/etc/group-group account Information

/etc/gshadow-secure Group account Information

Cases:

Add a user group

The code is as follows:

[Root@blackghost ~] Groupadd mytest

Add a user group and specify the GID

The code is as follows:

[Root@blackghost ~] groupadd-g 444 test

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.