Task five manage user and user groups for Linux systems __linux

Source: Internet
Author: User
Tags switches

Step One: View users on Linux systems

All users in the system hold files as/etc/passwd, which can be opened by the "vim/etc/passwd" command.


The first is the username: it uniquely identifies a user account.

The second is an encrypted password: the password stored in the passwd file is encrypted.

The third is the user id: The user identification code, the short UID.

The fourth one is the group ID: the user Group identification code, referred to as GID.

The fifth one is User directory: Annotate user account.

The sixth is home directory: This directory belongs to this account, when the user logged in it will be placed in this directory, it is like back home.

The seventh one is the login shell: The command that the user executes after logging in.

Step Two: View the user password and the valid file

The user password and the stored file for the validity period/etc/shadow can be opened through the "Vim/etc/shadow" command.


The first is the username: a user account that is consistent with the login in the/etc/passwd file.

The second is an encrypted password: The encrypted user password character is stored, with a length of 13 characters.

The third is the last modification time: The number of days from a certain point to the last time a user modifies a password.

The fourth is the minimum time interval: the minimum number of days required to modify the password two times.

The fifth is the maximum time interval: The maximum number of days that the password remains valid.

The sixth is the warning time, which indicates the number of days from the beginning of the system warning to the user's official password failure.

The seventh is inactivity time: the maximum number of days that the user does not have logon activity but the account remains valid.

The eighth one is the expiration time: The given is an absolute number of days.

"Vim/etc/shadow" edits the stored file for the user's password. Delete the character between the first colon and the second colon user2, and set the User2 password blank.

Step three: View the group file that the account belongs to

Each time a user is established in Linux, a group with the same name is also established, which by default is added to this group. The group user files are placed inside the/etc/group and can be viewed by the "vim/etc/group" command, as shown in Figure 5.1.


Figure 5.1

First column: User group name;

Second column: User group password;

Third column: GID, that is, group ID;

Fourth column: User list, each user is separated by commas; The text segment can be empty, if NULL indicates the user group is a GID username.

Step Fourth: View the user group password file

The Vim/etc/gshadow command allows you to view the user group password for a file, with one row per user group, as shown in Figure 5.2

Figure 5.2

First column: User group name;

The second column: the user group password, this paragraph may be empty or has the exclamation mark, if is empty or has the exclamation mark, indicated that does not have the password;

The third column: User group manager, this field can also be empty, if have multiple user group manager, use "," number division;

Column Fourth: Group members, if there are multiple users, separated by the "," number.

Step Fifth: Create and delete users

CentOS, the main command to create and delete users, as well as the following interpretation.

"Useradd yhy" creates a new Yhy user.

"Passwd yhy" sets a password for the yhy user, and the password is not displayed when it is lost.

"Useradd ybs-d/home/y" Creates a new YBS user and specifies that the home directory is/home/y.

"Useradd userl-d/Home/userl" can be without the-d argument, because the user default home directory is under/home under the same directory as the user name.

"Useradd user2" adds new user user2, user default home directory is/Home/user2.

"Userdel yhy" deletes the user, but does not delete the home directory.

"Userdel-r ybs" deletes the YBS user and deletes the home directory.

"Usermod-1 user2 UESRL" modifies the user name Userl to User2.

"Usermod-l user2" locks the user2 and cannot log in after locking.

"Usermod-u user2" unlock user2.

The "Su-suerl" root user switches to a normal user without a password.

The "su-root" Normal user switches to root and requires the root password.

Step Sixth: Establish and manage user groups

In CentOS, the main commands for establishing and managing user groups are as follows.

"Groupadd GRP1" new user group GRP1.

"Groupdel GRP1" deletes the user group GRP1.

"Groupmod grp2 GRP1" modifies the user name group GRP1 bit to GRP2.

"Gpasswd-a user2 grp2" adds the user user2 to the user group Grp2.

The "gpasswd-d user2 grp2" Removes the user user2 from the user group Grp.

Seventh step: Several important orders to supplement

"Who Am I" shows which user is currently logged on.

"W" Displays details of the user currently logged on to the system, including the login IP address.

The WHO displays brief information about the user who is currently logged on to the system.

"Last" records information such as the number of times each user logged on and the duration. "Finger" finds and displays user information.

"Su user" toggles the user but does not switch the current directory.

"Su-userl" toggles the user and transfers to the users home directory.

"Ntsysv" starts/shuts down services in the system.

Setup sets the system run parameters.

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.