First check the /etc/group file: [root@localhost /]# cat /etc/group root:x:0:root bin:x:1:root,bin,daemon daemon:x:2:root,bin,daemon sys:x:3:root,bin,adm adm:x:4:root,adm,daemon tty:x:5: disk:x:6:root lp:x:7:daemon,lp mem:x:8: kmem:x:9: wheel:x:10:root ... Each line of this file represents a user group, with colons separating the fields. There are 4 fields in total, namely:
Initial User Group The fourth field (GID) of the line corresponding to the user in /etc/passwd is the initial user group. When a user logs into the system, he or she immediately has the relevant permissions of this initial user group. [root@localhost /]# cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin ... Valid User Groups The effective user group indicates the user group that the user belongs to at this moment. Before the effective user group is switched, the effective user group is the initial user group. If you want to know the user's current effective user group and supported user groups (the fourth field in the /etc/group file contains the user's user group), use groups. [root@localhost /]# groups root bin daemon sys adm disk wheel In this output information, the first user group output is the current effective user group (but some systems do not do this). If I create a new file with touch, the owner of the file is root, and the user group is root (the effective user group). Switch effective user group: newgrp Use the newgrp command to switch the effective user group. Note that you can only switch the user groups supported by the current account. Assume that the current user supports the two user groups "test" and "foo". Then newgrp test and newgrp foo are valid. Everything else is invalid. The principle behind this conversion is to create a new shell. If you want to restore to the previous user group, you need to use exit or Ctrl+D to log out of the current shell. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed explanation of the entry-level use of MySql stored procedure parameters
>>: Summary of uncommon operators and operators in js
1. Build a Docker environment 1. Create a Dockerf...
As shown below: SELECT prod_name,prod_price FROM ...
This article shares the specific code for impleme...
Introduction to Linux alarm function Above code: ...
Zero, Background I received a lot of alerts this ...
This article takes the connection error ECONNREFU...
[LeetCode] 183.Customers Who Never Order Suppose ...
This article shares the specific code of React to...
Since we are going to upload pictures, the first ...
What is a tree in web design? Simply put, clicking...
Purpose Understand the Nginx ngx_http_limit_conn_...
Today I will introduce two HTML tags that I don’t...
This article example shares the specific code of ...
This is my first blog post. Due to time constrain...
Table of contents Implementing HTML Add CSS Imple...