Modify profile to create user under Linux

Source: Internet
Author: User
Tags md5 encryption openssl

1.1 User Profiles

[Email protected] ~]# head-1/etc/passwdroot:x:0:0:root:/root:/bin/bash

/etc/passwd There are 7 fields with a colon split, and one user corresponds to a record.


root: user name.

x: user password placeholder, the real password is encrypted and stored in the/etc/shadow file.

0: root user uid (User-id), System user ID is less than 500, normal user ID is greater than or equal to 500.

0: root user gid (Group-id), System group ID is less than 500, normal group ID is greater than or equal to 500.

Root: user's description information.

/root: root User's home directory, the home directory of ordinary users is generally located in the/home/user name.

/bin/bash: The shell used when the user logs on to the system.


[Email protected] ~]# head-1/etc/shadowroot:$6$huzf3bhdw.6ump0g$fsnji.yggootmuz53n0vdghy2rudu/h/ Riht4bdu1vhldylaog5/b5criegahrsozxfr3ksw77twvadczya5p1:16312:0:99999:7:::

/etc/shadow main storage parameters related to user password Total 9 fields are separated by a colon, and a user corresponds to a record.


Root: The user name corresponds to the user name in the/ETC/PSSWD.

Field 2: encrypt the user key through the MD5 encryption algorithm, if it is!! Indicates that the user password has not been created.

16312: The date that the password was last changed and the number of days separated by 1970-1-1.

0: Specify how many days after the password is set to change, and 0 stands ready.

99999: Password usage period, specify how many days after the password must be changed.

7: The number of days before the password expires, which indicates that the user has been prompted to change the password 7 days before the password expires.

Field 7: the account expiration date, the user password exceeds the specified use date does not change the password, until the account expires the time between the account in the expiration state, may let the administrator re-enable.

Field 8: the expiry date of the account is calculated starting from 1970-1-1 and cannot be used after expiration, generally for the charging system.

Field 9: reserved fields.


1.2 Sets of configuration files

[Email protected] ~]# head-2/etc/grouproot:x:0:bin:x:1:bin,daemon

/etc/group has 4 fields, separated by a colon.


Bin: group name.

x: group password.

1: Group ID (GID).

bin, daemon: user belonging to this group, separated by commas.

[Email protected] ~]# head-2/etc/gshadowroot:::bin:::bin,daemon

/etc/gshadow4 a field.


first field: user group.

second field: user group password, empty or! Represents no password.

third Field: the manager of the user group.

Fourth field: the user who belongs to the group, separated by commas.


2.1 Add user Modify/etc/passwd file

Requirements: Manually add user 51cto uid=1000,gid=1000 (wuyi), home directory is/home/51cto/.

Adds a line of 51cto user information to the/etc/passwd tail.

51cto:x:1000:1000:51cto-user:/home/51cto:/bin/bash


2.2 Add user Modify/etc/group file

Adds information for a row of 51cto user groups at the end of the/etc/group.

51cto:x:1000:51cto


2.3 Add user Modify/etc/shadow file

To generate a user MD5 password using the OpenSSL command:

[[email protected] ~]# OpenSSL passwd-1-salt ' 12345678 ' #-1 specifies that the encryption algorithm is MD5. #-salt Specifies 8-bit characters, and the same password and different-salt parameters also have different cryptographic strings. Password: #输入密码 $1$12345678$RC8MMKN1IV/J.MCNSNGGW.

Calculate today and 1970-1-1 days apart:

[[Email protected] ~]# date +%s1420121883 #距离1970-1-1 seconds.  [Email protected] ~]# BCBC 1.06.95Copyright 1991-1994, 1997, 1998, $, 2004, 2006 free software Foundation, inc.this Free software with absolutely NO WARRANTY. For details type ' warranty '. 1420121883/86400 #每天86400秒. 16436 #得到日期.

Add a 51cto user's password information to the/etc/shadow tail:

51cto:$1$12345678$rc8mmkn1iv/j.mcnsnggw.:16436:0:99999:7:::


2.4 Create 51cto User home directory:

[[email protected] ~]# cp-r/etc/skel//home/51cto# copy/etc/skel/directory to 51cto user home directory [[email protected] ~]# chown-r 51cto.51cto /home/51cto/#修改/home/51cto Directory Users and Groups are 51cto [[email protected] ~]# chmod-r go=/home/51cto/#修改/home/51cto directory permissions make Groups and other people do not have access rights.


2.5 Results verified:

[[email protected] ~]# su-51cto[[email protected] ~]$ Su-51ctopassword: ********************************************* Hello world!************************************************ [Email protected] ~]$

Using SU (switch-user) to switch to the user that you just created is not a problem with a successful configuration.














This article is from the "Linux Manual Creation user" blog, so be sure to keep this source http://xzb2015.blog.51cto.com/8796643/1598334

Modify profile to create user under Linux

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.