In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "can linux change read and write permissions". In daily operation, I believe many people have doubts about whether linux can change read and write permissions. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "linux can change read and write permissions". Next, please follow the editor to study!
Linux can change read and write permissions. In linux, read and write permissions can be modified using the chmod command, which controls user permissions on files, and can be set using octal number mode or symbol mode, with the syntax "chmod [- cfvR] [--help] mode file...".
The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
Linux can change read and write permissions.
In linux, you can use the chmod command to modify read and write 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.
Option description:
-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
Symbolic mode
Multiple items can be set using symbolic mode: who (user type), operator (operator), and permission (permission), and each item's settings can be separated by commas. The command chmod modifies the access to the file for the user type specified by who, which is described by the location of one or more letters in who, as shown in the symbolic pattern table of who:
Who user type description uuser file owner ggroup file owner group oothers all other users used by aall, equivalent to ugo
Symbolic pattern table for operator:
Operator description + add permissions to the specified user type-remove permissions for the specified user type = set the settings for the specified user permissions, that is, reset all permissions for the user type
Symbolic pattern table for permission:
The mode name indicates that r read permission w write is set to writeable permission x execution permission is set to executable permission X special execution permission is set only when the file is a directory file, or other types of users have executable permissions ssetuid/gid when the file is executed, set the file's setuid or setgid permission t paste bit according to the user type specified by the who parameter Only the superuser can set the bit, and only the file owner u can use the bit
Example:
If we want to set the permissions of the .bashrc file to rwxr-xr-x, we can execute the following command:
[root@localhost] # chmod uprirwx root@localhost. [bashrc] # ls-al .bashrc-rwxr-xr-x. 1 root root 176 Sep 22 2004 .bashrc
If you want to increase the write permissions for each user of the .bashrc file, you can use the following command:
[root@localhost] # ls-al. Bashrc-rwxr-xr-x. 1 root root 176Sep 22 2004. Bashrc [root@localhost ~] # chmod axiw. Bashrc [root@localhost] # ls-al. Bashrc-rwxrwxrwx. 1 root root 176 Sep 22 2004 .bashrc
Octal grammar
The chmod command can use octal numbers to specify permissions. The permission bits of a file or directory are controlled by 9 permission bits, each of which is a group of three. They are the read, write and execute of the file owner (User), the read, write and execute of the user group (Group) and the read, write and execute of other users (Other). Historically, file permissions have been placed in a bit mask, and the bit specified in the mask has been set to 1 to indicate that a class has a corresponding priority.
# permission rwx binary 7 read + write + execute rwx1116 read + write rw-1105 read + execute r-x1014 read-only rMurray 1003 write + execute-wx0112 write only-WMurray 0101 only execute-x0010 none-- 000
For example, 765 would explain:
The owner's permissions are expressed in numbers: the sum of the three permission bits that belong to the master. For example, rwx, that is, 4 / 2 / 1, should be 7.
The permissions of a user group are expressed in numbers: the sum of the digits of the permissions that belong to the group. For example, rw-, that is, 4 / 2 / 0, should be 6.
Digital expression of permissions of other users: the sum of the digits of other users' permissions. For example, rmurx, that is, 4, 0, 1, should be 5.
Example:
You can modify the permissions of the .bashrc directory file by using the following command:
[root@localhost] # ls-al .bashrc-rw-r--r--. 1 root root 176Sep 22 2004. Bashrc [root@localhost] # chmod 777. Bashrc [root@localhost] # ls-al. Bashrc-rwxrwxrwx. 1 root root 176 Sep 22 2004 .bashrc
For another example, usually after we edit a Shell file batch file with Vim, the file permission is usually rw-rw-r-- (644), so if you want to make the file executable and do not allow others to modify the file, you only need to set the file's permission to rwxr-xr-x (755).
At this point, the study on "can linux change read and write permissions" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.