Linux User management of the use of each command

Source: Internet
Author: User
Tags stdin

The Year of UNIX is 1970 January 1

The current version of the system, whether it is win or Linux most follow the 3A user and Rights management mechanism (authencattion authentication mechanism, authorzation authorization, Accounting Audit)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/29/wKiom1XduhqQ4UidAAF_MPrrbP0906.jpg "title=" 1.jpg " alt= "Wkiom1xduhqq4uidaaf_mprrbp0906.jpg"/>

, when the user entered the user name password, the system by looking for the corresponding uid,gid in the passwd file, and the information of the group to confirm that the user exists or not, if there is, then login to the account, perform the operation, if not, then re-login.


[Email protected] ~]# CAT/ETC/PASSWD

Root:x:0:0:root:/root:/bin/bash

The above content is the information of the related root in my passwd, which is username,password,uid,gid,gecos,homefile,shell from left to right.

Username Needless to say, basically know, according to the role, the authority will be different username

Password encrypted password file information, in centos5.x and the following encryption method is MD5, but in CENTOS6 and above as if the encryption is sha512, and saved in the/etc/shadow file

UID User ID number, the machine through the ID number to find your user name and password information is correct, the number of 0-65535

Among the ordinary users: 1-60000

System users:

centos6:1-499

centos7:1-999

Login User:

centos6:500+

centos7:1000+

GID groupname group ID, used to assign the user's permissions and roles, its main configuration file is/etc/gshadow and/etc/group, some company's mail system is basically used to differentiate functions, Linux for the group of sub- With:

Administrators group: 0

Normal Group:

centos6.x:1-499

centos7.x:1-999

Login User:

centos6.x:500+

centos7.x:1000+

GECOS Some details about the user

Homefile home directory, storing some personal role users ' files

Shell User Default Shell

Note:The/etc/shadow file manages the user's password information for one-way irreversible files, such as the following code files:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/26/wKioL1Xdz5zgvRfFAAIrAXHB3lE726.jpg "title=" 3.jpg " The alt= "Wkiol1xdz5zgvrffaairaxhb3le726.jpg"/> is in the following format:

Login name:encrypted password:date of last password change:minimum password age:maximum password Age:password warning Peri Od:password Inactivity Period:account Expiration date:reserved field

His data were separated by ":" or "$".

Related commands for user and group management:

Useradd, Usermod, passwd, Userdel

Groupadd, Groupmod, GPASSWD, Groupdel

Chage, Chsh, CHFN

ID, W, who, WhoAmI

Su


Useradd: Create User

useradd [Options] LOGIN

useradd-d [Options]

-r: Create a System user

-U uid: Specifies uid;

-G GID: Specifies the base group to which the user belongs, which must exist beforehand

-C ' COMMENT ':

-d/path/to/somewhere: Specifies the user's home directory path; This location cannot exist beforehand, otherwise its user-related profile will be to copy;/etc/skel.

-S Shell: Sets the user's default shell;

Cat/etc/shells

-G GID,... : Specifies the additional group to which it belongs;

-M: Do not create home directory for users;

Groupadd: Creating Groups

Groupadd [OPTIONS] GROUPNAME

-G GID: Indicates the group ID;

-r: Create a system group;

[Email protected] ~]# Groupadd Database

[[email protected] ~]# Groupadd SQL

ID: View user-related ID information;

ID [OPTION] ... [USER]

-u:uid

-g:gid

-g:groups

-n:name

[Email protected] ~]# id-g Oracle

3000 501 502

Su:switch user, switch users or execute commands as other users;

Switching mode:

Su USERNAME: Non-complete switching, non-login switching

Su-username or su-l USERNAME: full switch, login switch


Executes the specified command only as the specified user:

Su-username-c ' COMMAND '


Usermod: User Property modification

Usermod [OPTION] ... LOGIN

-U UID

-G GID

-G Gid[,gid,...] : Modify the additional groups that the user belongs to, and use the-a option;

-S SHELL

-C ' COMMENT '

-D Home: When the user's home directory is modified to a new location, the user's original file is not moved to the new home; the-m option allows it to be moved to a new home directory at the same time;

-L LOGIN:


-l:lock User

-u:unlock User

[Email protected] ~]# Useradd Nicai

[Email protected] ~]# usermod-l oralce Nicai

[Email protected] ~]# CAT/ETC/PASSWD

Oracle:x:3000:3000::/home/database:/bin/bash

Oralce:x:3001:3001::/home/nicai:/bin/bash


passwd: Add a password to the user

passwd [OPTION] [UserName]


-l:lock User

-u:unlock User


-N mindays: Minimum period of use;

-X maxdays: Default is 99,999 days;

-W Warndays:

-I. Inactivedays:


--stdin: Receive user password from standard output;


echo ' CentOS ' | passwd--stdin CentOS


Userdel: Deleting users

Userdel [-R] USERNAME

-R: Delete the user's home directory at the same time;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/2B/wKiom1XeYlTg0uDEAAMO6p1pBx8337.jpg "title=" 5.jpg " alt= "Wkiom1xeyltg0udeaamo6p1pbx8337.jpg"/>


Groupmod: Group Property Modification

Groupmod [OPTION] GROUPNAME

-N group_name

-G GID


GPASSWD: Set password for group


NEWGRP: Toggles the base group for the specified group


Groupdel: Deleting a group

For example:

Create user Oracle, belongs to additional group database and Sql,id number is 3000, home directory is/home/database;

[Email protected] ~]# useradd oracle-g database,sql-u 3000-d/home/database650 this.width=650; src= http://s3.51cto. Com/wyfs02/m01/72/2b/wkiom1xewgzx9b-qaaea3zupuu0620.jpg "title=" 4.jpg "alt=" wkiom1xewgzx9b-qaaea3zupuu0620.jpg "/ >


Linux User management of the use of each command

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.