Manage user groups on Linux

Source: Internet
Author: User
Tags exit in
Article Title: manage user groups on Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
In Linux, any user has a specific user ID code (uid ). This number is unique for every user in the regional sub-system.

The same user group is unlikely. Each user has a quasi-prime group ID (gid), which exists in the/etc/groups file. Generally, a user's quasi-prime group can be a group that uses the same name or number as its or her user ID code. But in some systems, it can be a general group called "user.

Use the id command to locate your group, as shown below:

$ Id

Uid = 501 (joe) gid = 501 (joe) groups = 501 (joe), 100 (users)

In this example, user joe has a user ID code of 501, which belongs to both the joe group (501) and the user group (100 ). The ID code of his quasi-prime group is the joe group.

When you create a new file, Linux uses your user ID code and quasi-prime group ID code to assign ownership to the file. For example, if joe creates a new file, the user joe and the group joe will own the file, which is most likely to be written by both parties and read by all other users.

However, if joe wants to create files that can be written by other users in the group, he must change the ownership of the files. You can create a file by changing joe's quasi-prime group joe to the user (users. Run the newgrp command:

$ Newgrp users

$ Id

Uid = 501 (joe) gid = 100 (users) groups = 501 (joe), 100 (users)

This configures the user group as the ID code of the peer group of joe. From this point of view, both the user joe and the user group have all the resources they have created.

As long as you enter exit in the command line, anegong will reply to joe to his original group and use the id command to confirm that you have stored the quasi-prime group.

Related Article

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.