linux--Users and Groups

Source: Internet
Author: User

One: Linux user and group related configuration files:

/ETC/PASSWD: User and its attribute information (name, UID, base group ID, etc.);

Name:password:UID:GID:GECOS:directory:shell

User name: Password: UID:GID:GECOS: Home directory: Default Shell

/etc/group: Group and its attribute information;

Group_name:password:GID:user_list

Group name: Group Password: GID: List of users with the current group as additional groups (comma delimiter)

/etc/shadow: User password and its related attributes;

Username: encrypted Password: the date of the most recent password change: Minimum password Age: Maximum password Age: password warning Period: Password Disable period: Account expiration Date: Reserved field

/etc/gshadow: group password and its related attributes, including but not limited to information in/etc/group ;

User group: User group Password: User Group manager: team member

/etc/login.defs

Mail_dir/var/spool/mail

Pass_max_days99999 # password Max expiration

Pass_min_days0 # Two minimum interval to change password

Pass_min_len5 # Minimum password length, invalid for root

Pass_warn_age7 # How many days before the password expires start prompting


Uid_min 1000 # Minimum value of user ID

Uid_max 60000 # maximum value of user ID

Sys_uid_min 201 # Minimum value of system user ID

Sys_uid_max 999 # Maximum value of system user ID


Gid_min 1000 # Minimum value of group ID

Gid_max 60000 # Maximum value of group ID

Sys_gid_min 201 # Minimum value of system group ID

Sys_gid_max 999 # Maximum value of system group ID

Create_homeYes # is enough to create a user directory when using Useradd


UMASK 077


Usergroups_enab Yes # encrypt password with MD5


Encrypt_method SHA512 # Encryption mode


/etc/default/useradd

GROUP=100 # Start GID value

Home=/home # Home Directory Location

Inactive=-1 # Effective time, negative number is permanent, positive numbers represent days

Expire=

Shell=/bin/bash # Shell Path

Skel=/etc/skel # User home directory of the environment files, by default add the user's directory default file storage location;

Create_mail_spool=yes # Whether to create a mail pool


Two: User and group-related management commands:

user created: Useradd

useradd [options] LOGIN

-u UID: [Uid_min, Uid_max], defined in/etc/login.defs

-G GID: Indicates that the user belongs to the basic group, can be a group name, can also GID;

-C "COMMENT": User's comment information;

-d/path/to/home_dir: The home directory with the specified path;

-S Shell: Indicates the user's default shell program, the available list is in the/etc/shells file;

-G group1[,group2,... [, GROUPN]] : Specifies additional groups for the user, and the group must exist beforehand;

-r: Create a System user

Group creation: Groupadd

groupadd [OPTION] ... group_name

-G GID: Specifies the GID number; [Gid_min, Gid_max]

-r: Create a system group;

View user-related ID information: ID

ID [OPTION] ... [USER]

-u:uid

-g:gid

-g:groups

-n:name

to switch users or execute commands as other users: Su

su [Options ...] [-] [user [args ...]]

How to switch users:

su UserName: Non-login switch, that is, the target user's configuration file will not be read;

su-username: Login switch, will read the target user's configuration file; switch completely;

User Property modification: Usermod

usermod [OPTION] Login

-u uid: New UID

-G GID: New Basic Group

-G group1[,group2,... [, GROUPN]] : The new add-on group, the original additional group will be overwritten, if the original, you want to use the-a option at the same time, indicating append;

-S shell: new default shell;

-C ' COMMENT ': new annotation information;

-D home: New home directory, files in the original home directory will not be moved to the new home directory at the same time, to move, then use the-M option;

-L login_name: new name;


-l:lock The specified user

-u:unlock The specified user


-E yyyy-mm-dd: Indicates the user account expiration date;

-F INACTIVE: set inactivity period;


Add password to User: passwd

passwd [OPTIONS] UserName: Modify the password of the specified user, only the root user rights

passwd: Modify your password;

-L: Lock the specified user

-u: Unlock the specified user

-N mindays: Specifying the shortest period of use

-x maxdays: Maximum lifespan

-W warndays: How many days in advance to start warning

-I inactivedays: inactivity period;

--stdin: Receive user password from standard input;

Delete User: Userdel

Userdel [OPTION] ... login

-r: Delete user home directory;


Group Property Modification: Groupmod

groupmod [OPTION] ... group

-N group_name: New name

-G gid: New Gid;


Group deletion: Groupdel

Groupdel GROUP


Group Password: gpasswd

GPASSWD [OPTION] GROUP


-A user: Adds the user to the specified group;

-D User: Removes additional groups of users with the current group as the group name


-A user1,user2,...: Set up a list of users with administrative privileges


newgrp Command: Temporarily switch the basic group , if the user does not belong to this group, you need the group password;


Modify User properties: Chage

chage [OPTION] ... LOGIN

-D last_day

-E,--expiredate expire_date

-I.,--inactive inactive

-M,--mindays min_days

-M,--maxdays max_days

-W,--warndays Warn_days


#################################################################################

Modify the default minimum length of root passwd by modifying the/etc/pam.d/system-auth file

Password requisite pam_cracklib.so try_first_pass retry=3 type= minlen=4

This article from "Sable" blog, reproduced please contact the author!

linux--Users and Groups

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.