In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "examples of the use of chmod commands in Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Chmod is used to manage the permissions of files or directories. The permissions of files or directories are controlled by read (r), write (w) and execution (x) respectively.
Scope of authority and code name
The scope of permissions for files and directories, including:
U:User, the owner of a file or directory; g:Group, the group to which the file or directory belongs; o:Other, all users except the owner or group to which the file or directory belongs; and a:All, all users, including owners, groups, and other users.
The codes for permissions include:
R: read permission, numeric code is 4mitw: write permission, numeric code is 2transferx: execute or switch permission, numeric code is 1bot: there is no permission, numeric code is 0bot s: when the file is executed, the setuid or setgid permissions of the file are set according to the user type specified by the who parameter. Syntax and option description chmod syntax: chmod [- cfRv] [--help] [--version] [+ /-/ =] [file or directory.] chmod [- cfRv] [--help] [--version] [numeric code] [file or directory.] chmod [- cfRv] [--help] [--reference=] [--version] [file or directory.] Option description:-c or-- changes: the effect is similar to the-v parameter, but only the changed part is returned;-f or-- quiet or-- silent: no error message is displayed;-R or-- recursive: recursive processing, processing all files and subdirectories in the specified directory together;-v or-- verbose: display instruction execution;-- help: display online help information -- reference=: sets the permissions of specified files or directories to be the same as those of reference files or directories;-- version: displays version information; +: opens the permission setting of files or directories with permission scope; -: closes the permission setting of files or directories with permission scope; =: the permission setting of files or directories with specified permission scope. Example
First, let's look at the information about files and directories through the ls-l command:
Lsl
As shown in the figure above, taking it as an example, we analyze the meaning of each content in turn.
Line 1: total 16, which represents the total disk space occupied by the listed contents, in KB; column 1: dr-xr-xr-x, indicating the type and permissions of the file or directory; column 2: 4, indicating the number of links to the file or directory; column 3: bin.guo, indicating the owner of the file or directory; column 4: staff, indicating the group in which the file or directory resides Column 5: 136, indicating the size of the file or directory itself, column 6: Nov 24 11:26, indicating the last update time of the file or directory, and column 7: a, indicating the name of the file or directory.
The content of column 1 (except total) is particularly rich. Take dr-xr-x-r-x as an example (a total of 10 characters), we further analyze it:
The 1st character d represents the type of file or directory, including p for named pipe files, d for directory files, l for symbolic connection files,-for ordinary files, s for Socket files, c for character device files, and b for block device files. The 2nd-4th character rmurx indicates the owner permission of the file or directory; the 5th-7th character rmurx indicates the owner of the file or directory has the same group user rights; and the 8th-10th character rmurx indicates other user rights of the file or directory.
In addition, you may have noticed that some files or directories are followed by a character after their displayed permissions, or. Or @, specifically:
Displayed as @ in Mac terminals and as. In Linux systems.
This means that the file or directory to which it belongs has the SELinux security context tag open, and if not, it is not open.
Next, demonstrate some concrete examples of operation:
Example 1: add execution rights for all users to test-one example 2: cancel execution rights for test-one owner group users and write permissions for other users gxow example 3: recursively cancel execution rights for all users of folder a ccccc example 4: add all users to test-one example 5: cancel execution rights for test-one owners and all other users This is the end of the introduction of permission 670 "examples of the use of chmod commands for Linux" Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.