In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the example analysis of user groups and permissions in linux, which is very detailed and has a certain reference value. Friends who are interested must read it!
User group
In linux, each user must belong to a group, while there are three concepts of groups under Linux, as follows:
The owner of the document
User's group
Other groups
File owner:
Is the creator of the file, who creates the file, who is the owner of the file.
User's group:
When the current user of Linux creates a file, the group to which the file belongs is the group in which the user belongs
Other groups:
Except for the file owner and the users of the group, the other users of the system are all other groups of the file.
How do we look at the current logged-in user and the group to which the user belongs? Enter the following command under the terminal:
1. Check the login user name?
Whoami: view the login user name
two。 Which user group does the currently logged in user belong to?
Groups: check which user group the currently logged in user belongs to
If you want to see the corresponding details further, you can enter the following command:
1.cat / etc/passwd | grep loguser capture user details # Echo information is as follows: > > loguser: X: 889: 600 home/loguser:/bin/bash user name: password: user ID: location group ID: remarks: user home directory: shell directory 2.cat / etc/passwd | grep weblogic grab user group details weblogic: x:500:600::/weblogic:/bin/bash# corresponding relationship is consistent with the user relationship.
Why do we talk about groups? in fact, it has something to do with the permissions that we talk about next.
File permissions
Every time we look at the details of the files in the current directory through ll, we can see the following at the front of the file:
Drwxrwxrwxlrwxr-xrw-
As shown in the figure, there are a total of 10 digits. Excluding the first digit, the remaining 9 digits start from left to right, and every three letters represent a category. In this way, there are a total of three groups, and the three categories here correspond to the above user groups:
To remove the first letter:
The first three represent the permissions of the owner of the file to the file
The middle three represent the permissions of the group to which the current user belongs to this file.
The last three represent the permissions of other user groups on this file
The first represents the type of file:
D directory file.
L symbolic link (points to another file, similar to a shortcut under a plague).
S socket file.
B block device file, binary file.
C character device file.
P name the pipe file.
Let's continue to discuss the meaning of the three letters rwx:
R (Read, read): for files, you have permission to read the contents of files; for directories, you have permission to browse directories.
W (Write, write): for files, it has the permission to add, modify and delete the contents of files; for directories, it has the permission to create, delete, modify and move files in the directory.
X (Execute, execute): for files, you have permission to execute files; for directories, the user has permission to enter directories.
one
two
three
Command to change permissions
In fact, the above rwx also has the following corresponding relationship:
Each letter corresponds to a number.
R ~ () w _ () ~ () x-2 ^ 2, 2 ^ 1, 2 ^ 0
R:4
W:2
X:1
Students who have studied computer principles must be well aware of 8421. In fact, this almost corresponds to this meaning.
So we sometimes see the following command to change permissions:
1. Method 1 for modifying permissions:
Chmod 755 abc
In fact, it is giving permission to abc: rwx rmurx Rmerx.
Rwx = 7, rMurray 5, rMurray 5
It's just a correspondence of what it looks like.
two。 Method 2:
U: user permission
G: group permissions
O: other user rights in different groups
The above has already been introduced, but again I don't have much explanation.
+: join
-: remove
=: settin
Chmod uplix abc is the permission that the file owner of abc can execute.
The above is all the contents of the article "sample Analysis of user groups and permissions in linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.