Users and user groups in Linux

Source: Internet
Author: User

In Linux, there are three types of users:
    • Root user : Also known as Superuser, has full control over the system. Super users can run any command without restrictions. The Root user can be viewed as a system administrator.
    • System User: System user is the user that Linux needs to run some programs, such as Mail user, sshd user, etc. System users are typically required for system functionality and are not recommended to modify these users.
    • Ordinary Users: General users are ordinary users, these users have limited access to system files, can not execute all Linux commands.

Linux supports groups of users, which are collections of users with the same characteristics. A group can contain multiple users, and each user can belong to a different group. User groups play an important role in Linux, allowing administrators to centrally manage users. When a user is a member of more than one group at the same time, the primary group that the user belongs to is recorded in the/etc/passwd file, which is the default group to which the login belongs, and the other groups are called additional groups.

The \etc folder in the root directory mainly contains the system profile and user, user group profile, where we can view details of users and user groups.

System files related to users and groups:

System files

Description

/etc/passwd Save information such as user name and password, each user in the Linux system has a corresponding record line in the/etc/passwd file. This file is readable for all users.
/etc/shadow The record lines in/etc/shadow and/etc/passwd in the Pwconv command are generated automatically according to the data in the/etc/passwd, which is similar in format to/etc/passwd, except that the password is encrypted. Not all systems support this file.
/etc/group All information for the user group is saved in the form of a record row.

Take a look at the structure of the /etc/passwd file:

$cat/etc/passwdROOT:X:0:0:superuser:/:d aemon:x:1:1:system daemons:/ETC:BIN:X:2:2:owner of System commands:/BIN:SYS:X:3:3:owner of System files:/usr/SYS:ADM:X:4:4:system accounting:/usr/ADM:UUCP:X:5:5:UUCP administrator:/usr/lib/uucp:auth:x:7:21:authentication ADMINISTRATOR:/TCB /files/auth:cron:x: 9: 16:cron daemon:/usr/spool/cron:listen:x:37:4:network daemon:/usr/net/nls:lp:x:71:18:printer Administrator:/usr/spool/lp:sam:x:200:50:sam San:/usr/sam:/bin/sh          

As you can see, a row of records in the/etc/passwd file corresponds to a user, and each row of records is separated by a colon into 7 fields, in the format and meaning of the following: Description of each field:

Field Description
User name The user name is unique, and the length is based on different Linux systems, typically 8 bits.
Password Since there is also a/etc/shadow file in the system to hold the encrypted password, this is an "x" in this case, if the user does not set the password, the entry is empty. If the first character in the passwd field is "*", then the account is blocked and the user who owns the account is not allowed to log in.
User ID There are several user IDs that identify different users within the system based on user ID rather than user name:
  • 0 for system administrators, if you want to create a system administrator, you can create a regular account, and then change the user ID of the account to 0.
  • 1~500 the system reserved ID.
  • More than 500 is used by ordinary users.
Group ID In fact, this is the same as the user ID, used to manage the group, related to the/etc/group file.
Description information This field is almost useless, just to explain the meaning of the account. In different Linux systems, the format of this field is not uniform. In many Linux systems, this field holds an arbitrary annotated descriptive text that is used as the output of the finger command.
User home Directory The starting directory for the user to log on to the system. When the user logs in to the system, it enters the directory first. Root user default is/, ordinary user is/home/username.
User shell The shell used when the user logs on to the system.

Structure of the /etc/shadow file:

/etc$SudoCatshadow[sudo] PasswordFortest:root:$6$w2kscbfb$rpaan0ny. GG5.9L8LECZ7CW5J.V1RYLTJAZPHH/5ZWSKRIBSEVUHSSKWXNCWLLFSV0K1GMAP90DZF6V894FJ1:16958:0:99999:7:::d aemon:*:16911:0:99999:7::: bin:*:16911:0:99999:7::: sys:*:16911:0:99999:7:::sync:*:16911:0:99999:7:::games:*:< Span style= "color: #800080;" >16911:0:99999:7< Span style= "color: #000000;" >:::man:*:16911:0:< Span style= "color: #800080;" >99999:7:::lp:*:< Span style= "color: #800080;" >16911:0:99999:7< Span style= "color: #000000;" >:::mail:*:16911:0: 99999:7:::           

Format-user name: password: The date of the most recent password change: The number of days the password cannot be changed: the number of days that the password needs to be changed: the warning date before the password change period: grace period for password expiration: account expiry time: reserved field

Field Description
User name The user name is unique, and the length is based on different Linux systems, typically 8 bits.
Password The encrypted password. If the first character in the field is "*", then the account is blocked and the user who owns the account is not allowed to log in.
Date the password was last changed

16911 this figure is due to January 1, 1970 as the 1th Day, and then + + to get.

number of days that a password cannot be changed User cannot change password within specified number of days
Number of days the password needs to be re-changed Password must be changed after a specified number of days
Warning Date before the password change period The starting directory for the user to log on to the system. When the user logs in to the system, it enters the directory first. Root user default is/, ordinary user is/home/username.
A wide time limit for password expiration You can continue to use it within the specified time after the account expires
Account Expiry time Account is automatically deactivated for more than the specified time
Reserved fields There is no meaning at the moment and may be saved for later expansion

/etc/group structure:

/etc$sudo Catgroup[sudo] Password fortest:root:x:0:d aemon:x:1: bin:x:2: sys:x:3: adm:x:4: syslog,testtty:x:5:d isk:x:6:LP: x:7: mail:x:8: news:x:9: uucp:x:Ten:Mans: x: A:p roxy:x: -:

format-- group name : Password: Group ID: member

Should not need to explain, as long as the attention "X" for the password, the specific password exists in shadow.

Users and user groups in 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.