Unix group and user operations

Source: Internet
Author: User

Introduction to unix peer groups and user operations: This article describes linux users and groups, how to create groups and users, and how to change relevant content: /etc/group,/etc/gshadow/,/etc/passwd,/etc/shadow 1, group www.2cto.com 1. create groupadd-g 555 ddclick [Create ddclick group, GID is 555] 2. add a new user gpasswd-a tony ddclick to the group [add tony to the ddclick group] 3. remove gpasswd-d tony ddclick from the group [remove tony from the ddclick group] 4. other groupdel ddclick [Delete ddclick group] groupmod-n ddclick storm [change the ddclick group name to storm] ------------------------- Users www.2cto.com 2. User 1. Use useradd to add user Useradd student1. Create the default working directory of user st1:/home/username. You can specify other directories as the working directory, for example: useradd student3-d/student/student3 user's default UID increases from 500 to the next order. You can specify UID. For example, if useradd-u 600 student4 does not specify the working group to which the user belongs, a working group with the same name as the user name will be generated during User Creation, you can also specify a Working Group when creating a user. Example: useradd-g student 5 2. Use passwd to set a password for the user. Example: passwd student1 3. Modify usermod user account. Example: Change the username of user student1 to st1, usermod-l st1 student1 example: add the user to the student group, Usermod-g student student1 example: change the user directory to/student/student1 usermod-d/student/student1 student 4. Use userdel to delete a user account. Example 2: delete user student2 userdel student2: delete user student3, delete his working directory Userdel-r studenet3 5 and [color = red] to view User information --- id [color] id command to view the UID and GID of a user, for example: View student4 Id Id student4 finger command-you can view the user's home directory, startup shell, user name, address, phone number, and other information. Example: finger student4 ----------------------------- demarcation line 3,/etc/gshadow explanation;/etc/gshadow is an encrypted information file of/etc/group, such as a user Group) the management password is stored in this file. /Etc/gshadow and/etc/group are complementary files. For large servers, you can customize some permission models with complex relational structures for many users and groups, it is essential to set the user group password. For example, we do not want some non-user group members to have the permissions and features of the user group permanently. In this case, we can use password verification to allow some users to temporarily have some user group features. In this case, we need to use the user group password; the format of/etc/gshadow is as follows, with each user group exclusive row; groupname: password: admin, admin ,...: member, member ,... field 1: User Group Field 2: user group password, which can be empty or !, If it is null or there is !, Indicates that there is no password. The third field is the user group administrator. This field can also be blank. If there are multiple user group administrators, separate them with commas (,). The fourth field is group members. If there are multiple members, separated by commas (,). Example: beinan :!: Linuxsir: oUS/q7NH75RhQ: linuxsir Field 1: In this example, two user groups, beinan, use linuxsir Field 2: user group password. beinan user group has no password; the linuxsir user group already exists and has been encrypted. The third field is the user group administrator. Both are empty. The fourth field is the linuxsir, which is the member of the beinan user group, check/etc/group and/etc/passwd to see if there are other users. Generally, users are added by default, and sometimes the user group and user name are created with the same name; the linuxsir user group has a member linuxisir. How do I set the user group password? We can achieve this through gpasswd. However, in general, there is no need to set the user group password, but it is also necessary to practice it yourself. Below is an example of setting a password for the linuxsir user group; usage of gpasswd: gpasswd User 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.