User Identification of basic UNIX knowledge

Source: Internet
Author: User
Tags integer numbers

I. User ID

The user ID in the password file (/etc/passwd) is a numerical value, which identifies different users to the system. The system administrator determines the user ID while determining the login name of a user. Users cannot change their user IDs. Generally, each user has a unique user ID.

If the user ID is 0, root or superuser is used ). In the password file, there is usually a logon entry whose login name is root. We call this user's privilege as the Super User Privilege. If a process has the superuser privilege, most File Permission checks are not performed. Some operating system functions are only available to Super Users, and Super Users have the right to control the system.

Ii. Group ID

The logon entry of the password file also includes the user's group ID, which is a numerical value. The Group ID is also assigned by the system administrator when the user logon name is specified. Generally, multiple record items in the password file have the same group ID. A group is used to assign several users to different project groups or departments. This mechanism allows all members in the same group to share resources (such as files ).

The group file maps the group name to a numeric group ID, which is usually/etc/group.

For permissions, numerical user IDs and numerical group IDs are historically formed. For each file on the disk, the file system stores the user ID and group ID of the owner of the file. It takes only four bytes to store these two values (assuming that each value is a double-byte integer value ). If you use the full-length ASCII login name and group name, more disk space is required. In addition, it takes more time to compare strings than compared integer values during the permission check.

However, it is easier for users to use names than to use numeric values. Therefore, the password file contains the ing between the login name and user ID, while the group file contains the ing between the group name and the group ID.

Note: Early UNIX systems used 16-bit integer numbers to represent user IDs and group IDs. Today's UNIX systems use 32-bit integer numbers to represent user IDs and group IDs.

Program list 1-7 print the user ID and group ID

[root@localhost unix_env_advance_prog]# cat prog1-

Call getuid and getgid to return the user ID and group ID. Run this program and generate:

[root@localhost unix_env_advance_prog]# ./prog1-= , gid = 
3. Additional Group

In addition to specifying a group ID for a login name in the password file, Most UNIX system versions allow a user to belong to another group. This is from 4.2BSD and allows one user to belong to up to 16 other groups. When logging on, read the file/etc/group and find the first 16 record items that the user is a member of to get the user's additional group ID (supplementary group ID ). POSIX requires the system to support at least eight additional groups. In fact, most systems support at least 16 additional 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.