Explanation of Useradd and usermod command parameters in Linux system

Source: Internet
Author: User

Useradd command, add User:

ReferencenumberDescriptiondescribed  
- C Comment Add a note to a new user 
- D home_dir specify a name for the main directory (if you do not want to use the login name as the main directory) 
- e expire_date withYYYYY-MM-DDformat Specifies the date on which an account expires 
- F inactive_days specify how many days after this account password expires this account is disabled;0indicates that the password is disabled immediately after it expires,-1indicates disabling this feature 
- g Initial_group that specifies the user logon group.GIDor group name 
- G Group ... specify one or more additional groups to which the user belongs except for the logon group 
- k must and- Mused together, the/etc/skelThe contents of the directory are copied to the user'sHOMECatalogue 
- m Create a user'sHOMECatalogue 
- m do not create a user'sHOMEdirectory (only used when creation is specified in the default settings) 
- N Create a new group with the same name as the user login 
- R Create a System account 
- p passwd Specify a default password for a user account 
- s Shell Specify default loginShell
- u uid assign a unique to the accountUID

Similarly, you can use- Dparameter to modify the default new user value for the system, followed by a parameter to modify the value. These parameters are shown in the following table:
============================================================================ 
参 数描 述 
---------------------------------------------------------------------------- 
-b default_home 更改默认的创建用户HOME目录的位置 
-e expiration_date 更改默认的新账户的过期日期 
-f inactive_days 更改默认的新用户从密码过期到账户被禁用的天数 
-g group 更改默认的组名称或GID 
-s shell 更改默认的登录shell 
============================================================================ 
as#useradd-D-s/bin/tsch, modify the defaultShellto be/bin/tsch.



Usermod Modify the System account file and the related changes specified on the command line.

Options

Usermod The options you can accept are:

-A,--append adds a user to an additional group. Can only be used with the- g option.

- c,--commentcomment the new value of the Comment field in the user password file. It is usually modified using the CHFN (1) tool.

-D,--homehome_dir the user's new login directory. If the - m option is given , the contents of the current home directory will be moved to the new home directory and created if it does not exist.

& nbsp;     -E,--expiredateexpire_date The date on which the user account will be disabled. Date with yyyy-mm-dd format specified. Null expire_date /etc/passwd Span style= "font-size:13px;font-family: ' The song body '; background: #FFFFFF;" > file. If not, you will create a /etc/shadow project.

- F,--inactiveinactivethe number of days before the account is completely disabled after the password expires. 0indicates that the account is disabled immediately when the password expires;-1indicates that this function is not used,This option requires a/etc/passwdfile. If not, you will create a/etc/shadowProject.

- g,--Gidgroup the group name or number designator of the user's new initial logon group. This group must exist. In the user home directory, the files that belong to the original primary group are forwarded to the new group. A group that belongs to a file other than the home directory must be manually modified.

-G,--groupsgroup1[,group2,... [, GROUPN]] the list of additional groups that the user also belongs to. Groups are separated by commas with no spaces. These groups are subject to the same restrictions as those given in the-G option. If the user is currently a member of a group, and the group is not listed here, the user will be removed from that group. This behavior can be modified by the -a option, which allows the user to append to the list of attached groups given.

-L, the name of the--loginnew_login user will be modified from LOGIN to new_login. will not change anything else. In particular, the user's home directory name and Mail pool also need to be manually modified to correspond to the new login name

-L,--lock locks the user's password. This will place a "!" before the user encrypts the password. , you can quickly disable the password. You can Use this option with-P or-U. Note: If you want to lock your account ( not just through password access ), you will also need to set expire_date to 1.

-M,--move-home moves the user's home directory to a new location. This option is only valid if used in combination with the-D ( or --home) option. usermod will overwrite the owner of the file and copy the schema,ACL, and extended attributes, but may also need to be modified manually later.

-O,--non-unique You can change the user ID to a non-unique value when you use the-u option.

-P,--passwordpassword the password that has been encrypted, as crypt (3) returns. Note: This option is not recommended because passwords ( or encrypted passwords ) are seen by the user by listing this process. You should ensure that the password complies with the system's password policy.

-R,--rootchroot_dirapply changes in the Chroot_dir directory and use the Configuratiofiles fromthe chroot_dir directory.

-S,--shellshell the name of the user's new login shell . Setting this field to null causes the system to select the default login shell.

-u,--uiduid user ID -o option, which must be non-negative. The user's mailbox, the main ID of the file belonging to this user in the user's home directory /etc/login.defs uid_min, Uid_max, sys_uid_min check.

-U,--unlock unlocks the user's password. This will remove the encrypted password before the "! ". You can use this option with- p or -L. Note: If you want to unlock your account ( not just access with a password ), you should also set expire_date (for example, set to 99999, or /etc/default/ The EXPIRE value in the useradd).

-Z,--selinux-userseuserusers logged inSELinuxuser. The EmptySeuserwill remove the userLOGINof theSELinuxUser Mappings(if there is).




Useradd and usermod command parameters in Linux systems explained

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.