In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Today, I would like to talk to you about how to modify the permissions of linux, many people may not know much about it. In order to make you understand better, the editor summarized the following content for you. I hope you can get something according to this article.
In linux, you can modify file permissions with the chmod command, which controls the user's permissions on the file with the syntax "chmod [- cfvR] [--help] [--version] mode file...".
The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
How does linux modify permissions
The Linux chmod command is a command that controls the user's permissions on a file.
The file call authority of Linux/Unix is divided into three levels: file owner (Owner), user group (Group), and other users (Other Users).
Only file owners and superusers can modify the permissions of a file or directory. You can use absolute mode (octal number mode), and symbolic mode specifies the permissions of the file.
Permissions: all users
Grammar
Chmod [- cfvR] [--help] [--version] mode file...
Parameter description
Mode: permission setting string, in the following format:
[ugoa...] [[+-=] [rwxX]...] [,...]
Where:
U indicates the owner of the file, g indicates that the owner belongs to the same group (group) as the owner of the file, o indicates someone other than others, and an indicates all three.
+ means to increase permissions,-to cancel permissions, and = to set permissions uniquely.
R means readable, w means writable, x means executable, and X means only if the file is a subdirectory or if the file has been set to executable.
Description of other parameters:
-c: if the permission of the file has indeed been changed, the change action will be displayed.
-f: do not display an error message if the file permissions cannot be changed
-v: displays the details of permission changes
-R: make the same permission changes for all files and subdirectories in the current directory (that is, change them one by one recursively)
-- help: displays auxiliary instructions
-- version: display version
There are nine basic permissions for Linux files, and each of the three identities of owner/group/others has its own read/write/execute permissions.
For example: the permission character of the file is-rwxrwxrwx. These nine permissions are in groups of three! Among them, we can use numbers to represent each permission. The score comparison table of each permission is as follows:
R:4 w:2 x:1
The three r/w/x scores for each owner/group/others need to be accumulated, for example, when the permission is: [- rwxrwx---] the score is:
Owner = rwx = 4 "2" 1 = 7group = rwx = 4 "2" 1 = 7 others =-= 0 "0" 0
So when we set the permission change, the permission number of the file is 770! The syntax for the directive chmod to change permissions is as follows:
[root@www ~] # chmod [- R] xyz file or directory
Options and parameters:
Xyz: the permission attribute of the numeric type just mentioned, which is the sum of the values of the rwx attribute.
-R: make continuous recursive changes, that is, all files in the subdirectory will change.
For example, if you want to enable all permissions for the .bashrc file, issue:
[root@www ~] # ls-al .bashrc-rw-r--r-- 1 root root 395 Jul 4 11:45. Bashrc [root@www ~] # chmod 777. Bashrc [root@www ~] # ls-al .bashrc-rwxrwxrwx 1 root root 395 Jul 4 11:45 .bashrc
What if you want to change permissions to-rwxr-xr--? Then the score of permission is [4 / 2 / 1] [4 / 0 / 1] [4 / 0 / 0] = 754! So you need to issue:
[root@www ~] # chmod 754 filename read the above content, do you have any further understanding of how linux modifies permissions? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.