Mylinux Note---6th day

Source: Internet
Author: User
Tags stdin

First, view the user

/etc/passwd

[Email protected] ~]# Cat/etc/passwd|head-5root:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon : x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinlp:x:4:7:lp:/var/spool/lpd:/sbin/nologin[ [Email protected] ~]#

Each line of the file represents a user,

Each line is separated by a colon ":" Into 7 fields,

Structure is the same, the structure is as follows:


User name: Password: uid:gid: User tag: Home directory: Shell


① User name: uppercase and lowercase letters, numbers, minus signs (not appearing in the first place), dots, and underscores, other characters are illegal.

② Password: the "x" letter placeholder, in fact the password is stored in "/etc/shadow".

[Email protected] ~]# head-5/etc/shadow root:$6$zj4ryp1lfptznzdm$ jzbdsgce0pnze6pev9l8ncoxmohr90cfzubxikl2ookjhveeup/uydg6unninkvqmizd6dsan5pwudnxng.qe0:16496:0:99999:7:::bin:* : 15980:0:99999:7:::d aemon:*:15980:0:99999:7:::adm:*:15980:0:99999:7:::lp:*:15980:0:99999:7:::[[email protected] ~]#

③uid:user ID User Identification Code, the special value "0" is saved to "root", 1~499 belongs to the system user, 500~4294967294 (2^32-2) is assigned to the ordinary user.

④gid:group ID User Group identification code, from "/etc/group".

[Email protected] ~]# head-5/etc/group root:x:0:bin:x:1:bin,daemondaemon:x:2:bin,daemonsys:x:3:bin,admadm:x:4:adm , Daemon[[email protected] ~]#

⑤ User Tags: This field does not make any sense, usually records some of the user's properties, such as name, phone, address, etc., with CHFN change

[[email protected] ~]# grep  "Mylinux"  /etc/passwdmylinux:x:1000:1000::/home/mylinux:/ bin/bash             #  User Mylinux Fifth paragraph is empty; [[ email protected] ~]# chfn -f mylinux -p 13800138000 mylinux #   Add description-f full-name;changing finger information for mylinux.   with CHFN                  -p  Office-phone;finger information changed. [[email protected] ~]# !grep                               The      #  fifth paragraph has been added to the information just now grep  "Mylinux"  /etc/passwdmylinux:x:1000:1000: mylinux,,13800138000:/home/mylinux:/bin/bash[[email protected] ~]#

⑥home Directory: User home directory Location

⑦shell: Identify user shell type:/bin/bash;/sbin/nologin;/sbin/shutdown, etc.



Second, the user password

/etc/shadow

[Email protected] ~]# head-5/etc/shadowroot:$6$zj4ryp1lfptznzdm$ jzbdsgce0pnze6pev9l8ncoxmohr90cfzubxikl2ookjhveeup/uydg6unninkvqmizd6dsan5pwudnxng.qe0:16496:0:99999:7:::bin:* : 15980:0:99999:7:::d aemon:*:15980:0:99999:7:::adm:*:15980:0:99999:7:::lp:*:15980:0:99999:7:::[[email protected] ~]#

Each line of the file represents a user,

Each line is separated by a colon ":" Into 9 fields,


User name:

Password: MD5 encrypted, non-encrypted

Change password time: The last time you changed your password

Change Password Age: How many geniuses can be changed password, default value "0", unlimited

Password expiry time: the number of days after the password expires, the default value of "99999"

password Age: Password expiration reminder, default value "7" is the first 7 days before password expires reminder

Lockout period: after the password expires, the account number days after the lock, the default value is empty

life cycle: account life cycle, default value NULL

Reserved bits



Iii. Users and Groups

① user's creation/deletion

User-Created

format : useradd [options] [user name]

[Email protected] ~]# useradd linux[[email protected] ~]# tail-1/etc/passwdlinux:x:1002:1003::/home/linux:/bin/bash[ [Email protected] ~]#

option :-u Specify user uid

-U Specify user group

-g Specifies the user gid (to contain this ID in passwd)

-G Specify user group GID

-M Create user home directory

-M do not create user home directory

-D User Home directory

-D print or change useradd default configuration

-s Specifies the shell type

User Delete

format : Userdel [options] [user name]

[[email protected] ~]# tail-5/etc/passwdnfsnobody:x:65534:65534:anonymous NFS user:/var/lib/nfs:/sbin/nologinanon:x : 600:600:anonymous,,13800138000:/home/anon:/bin/bashwww:x:1001:1001::/home/www:/bin/bashanonymous:x:501:501::/ Home/anonymous:/bin/bashlinux:x:1002:1003::/home/linux:/bin/bash[[email protected] ~]# Userdel Linux[roo[email Protected] ~]#!tailtail-5/etc/passwdrpcuser:x:29:29:rpc Service user:/var/lib/nfs:/sbin/nologinnfsnobody:x : 65534:65534:anonymous NFS user:/var/lib/nfs:/sbin/nologinanon:x:600:600:anonymous,,13800138000:/home/anon:/bin/ Bashwww:x:1001:1001::/home/www:/bin/bashanonymous:x:501:501::/home/anonymous:/bin/bash[[email protected] ~]#

option :-F Force Delete

-R Delete User home directory and mail buffer



Creation and deletion of ② groups

Creation of groups

format : groupadd [Options] [group name]

[Email protected] ~]# groupadd linux[[email protected] ~]# tail-5/etc/groupanon:x:600:www:x:1001:anonymous:x:1002: Test:x:501:linux:x:1003:[[email protected] ~]#

option :-G to specify GID for the group created

-p to create a group encryption

-R Create a system account

Deletion of groups

format : Groupdel [Options] [group name]

[Email protected] ~]# Groupdel linux[[email protected] ~]# tail-5/etc/groupnfsnobody:x:65534:anon:x:600:www:x:1001: Anonymous:x:1002:test:x:501:[[email protected] ~]#



③usermod Modification of user information

Format: usermod [options] [user name]

[[email protected] ~]# tail-5/etc/passwdnfsnobody:x:65534:65534:anonymous NFS user:/var/lib/nfs:/sbin/nologinanon:x : 600:600:anonymous,,13800138000:/home/anon:/bin/bashwww:x:1001:1001::/home/www:/bin/bashanonymous:x:501:501::/ Home/anonymous:/bin/bashlinux:x:1002:1003::/home/linux:/bin/bash[[email protected] ~]# usermod-g 501 Linux # Switch to user GID information [[email protected] ~]#!tailtail-5/etc/passwdnfsnobody:x:65534:65534:anonymous NFS user:/var/lib/nfs:/sbin/ Nologinanon:x:600:600:anonymous,,13800138000:/home/anon:/bin/bashwww:x:1001:1001::/home/www:/bin/bashanonymous : X:501:501::/home/anonymous:/bin/bashlinux:x:1002:501::/home/linux:/bin/bash[[email protected] ~]#

Option:-L change User login name

-C Update user passwd in comment bar information

-D Specify a new user home directory

-g Specifies a new GID

-g Specifies the new group GID

-u Specifies the new user uid

-M mobile home directory to new location

-p Use new encryption password

-S using the new shell type

-L Lock user account

-U Unlock user account



Iv. Creating/modifying user passwords

Create a user password

For the new user, no password is set, the password needs to be created and the command is as follows:

[[email protected] ~]# passwd Linux # format passwd [username] Change the password of the user Linux. New Password: Re-enter the new password: passwd: All authentication tokens have been successfully updated. [Email protected] ~]#

Option:-D Delete the named account password

-k password not in period

--stdin obtaining a password from standard input

[[email protected] ~]# passwd linux--stdin change password for user Linux. 123456789PASSWD: All the authentication tokens have been successfully updated. [Email protected] ~]#



mkpaswd Password Generation command

There is no need for this command to perform Yum install-y expect

Option: The length of the-l password, the default value is "9"

-d password contains several numbers, the default value is "2"

-c password contains several lowercase letters, the default value is "2"

-c password contains several uppercase letters, the default value is "2"

-S password contains several special characters, the default value is "1"

-P Encrypt the program




Update in ...

This article is from the "Mylinux" blog, make sure to keep this source http://mylinuxlife.blog.51cto.com/4706737/1622655

Mylinux Note---6th day

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.