In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "what does Linux's r, w, x mean respectively?". The editor shows you the operation process through an actual case. The operation method is simple and fast, and it is practical. I hope this article "what is the meaning of Linux's r, w, x respectively" can help you solve the problem.
First, let's take a look at the contents of the files in the current directory.
Ls-l view the list of files in the current directory ls-l xxx.xxx (xxx.xxx is the file name) view the specified file
We can see the permissions of the file,-rw-rw-r-, which has a total of 10 digits.
Among them: the first one-represents the type (detailed as shown in the map below)
The middle three rw- represent the owner (user)
Then those three rw- represent group.
The last three r-represent other people (other)
Then I'll explain the last nine digits:
R indicates that the file can be read (read)
W indicates that the file can be written (write)
X indicates that the file can be executed (if it is a program)
-indicates that the corresponding permission has not been granted
File and folder operation permissions:
The role of permission abbreviations on ordinary files on folders read r view file contents list files in a folder (ls) write w modify file contents delete, add or rename files (folders) execute x files can be executed as a program cd to folder illustration:
It is important to note that a directory can only open and view internal files with both read and execute permissions, while a directory must have write permission to create other files in it. this is because the directory file actually holds information such as a list of files in the directory.
Add:
Special permissions SUID, SGID, Sticky also have three file permission attributes that are independent of the user's identity in the linux system. Namely SUID, SGID and Sticky. SUID (Set User ID, 4): this attribute is valid only for files with execute permissions, not for directories. When a program with SUID permission is executed, the owner of the raised process is the owner of the program file, not the user who started the program (unless they are the same person). For example, if the owner of a program is root and has the SUID attribute, a normal user executes the program just as root executes the program. (note that this property is not valid for Shell scripts.) this property facilitates the startup of some special programs, such as lpr. But sometimes it brings security risks: for example, if a program with the SUID attribute runs a shell when it is executed, then the user can get the highest privileges of the system. SUID can be expressed as s, for example: $ls-l / usr/bin/passwd-rwsr-xr-x 1 root root 47032 Feb 16 2014 / usr/bin/passwd
SGID (Set Group ID, 4): for executable files, SGID is similar to SUID in that all groups of processes raised are the groups to which the program file belongs. For a directory, the SGID property makes the group of the newly created files in the directory the same as that directory. SGID can also be expressed as s, for example, valid only for directories. A file or directory under an attribute directory can be deleted or renamed by its owner. Attributes are often used to create directories where group users can create new files and modify file contents, but only the file owner can delete or rename their own files. Such as folders in the system. In a property string, it is usually represented by. Ls-l / drwxrwxrw t 8 root root 4096 Apr 4 23:57 tmp
Modify the permissions of files and folders corresponding to users. If you have a file of your own that you do not want to be read, written or executed by other users, you need to modify the permissions of the file. Here are two ways:
Method 1: binary number representation
There are three sets of permissions for each file: U represents the owner (user) g represents the owner's group (group) o represents other people, but not u and g (other) a represent all the people, that is, including uMagazine g and o according to the figure above, where: rwx can also use numbers instead of r-4 w-2 x-1-0
When everyone understands the above, then some of our common permissions are easy to understand:-rw--- (600) only the owner has read and write access-rw-r-r- (644) only the owner has read and write access, groups and others have only read access-rwx-- (700) only the owner has read and write access. Permission to execute-rwxr-xr-x (755) only owners have read, write, execute permissions, groups and others only read and execute permissions-rwx-x-x (711) only owners have read, write, execute permissions Groups and others only have permission to execute-rw-rw-rw- (666) everyone has read and write access-rwxrwxrwx (777) everyone has read, write and execute access
Practical operation
After viewing the permissions of test, the owner has the permissions to read, write and execute:
Then add something to the file, change the permissions (700RWX), and try to read the file under shiyanlou (owner), which can be read.
Change to another user Peter, and try to read it again as shown in the figure below. It shows that the permission is insufficient and cannot be read.
Method 2: add and subtract assignment operation
U represents the owner (user) g represents the owner's group (group) o represents others, but not u and g (other)
A stands for all the people, that is to say, uJournal g and o
+ and-means to increase and remove the corresponding permissions, respectively. The + sign is usually not displayed (I will still add it when I learn to practice)
Enter chmod xxx.xxx chmod o w xxx.xxx at the terminal to grant others permission to write to the xxx.xxx file.
Chmod go-rw xxx.xxx means to delete the read and write permissions of groups and other people in xxx.xxx chmod ug-r xxx.xxx
Modify the owner / group of a file or folder use the command chown to change the ownership of a directory or file (owner / group)
Note: what is said here is intermittent and will be added after learning the next content (user / group addition, deletion, modification and query).
Files and directories can be changed not only by permissions, but also by ownership and user groups. Similar to setting permissions, users can set them through the graphical interface or execute chown commands to modify them. Let's first execute ls-l to look at the directory:
You can see that the user group of the test file is root and the owner is root. Execute the following command to transfer ownership of the test file in the above figure to user peter: # chown peter test
To change your group, transfer the test file from the root group to the group Peter, using the following command: # chown: peter test
Change the owner of the folder or file test to shiyanlou, and the group to shiyanlou, as shown below:
This is the end of the content about "what does Linux's r, w, x mean respectively?" Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.