In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article analyzes "what is the command for Linux system to modify file permissions". The content is detailed and easy to understand, "what is the command for Linux system to modify file permissions?" interested friends can follow the editor's train of thought to read it slowly and deeply. I hope it can be helpful to everyone after reading. Let's follow the editor to learn more about "what is the command for Linux system to modify file permissions".
Introduction: you can use the command chmod to grant permissions to files or directories. Linux/Unix 's access to files is divided into three levels: file owners, groups, and others. Chmod can be used to control how files are accessed by others.
There are two ways to use this command, one is chmod followed by a number, followed by a file name
Chmodabcfile
There is a number for User, Group, and Other respectively.
Renew4, want2, 2, 3, 1, 2, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
If you want the rwx property, then 4, 2, 1, 7.
If you want the rw- property, then 4 / 2 / 6
If you want the rmurx attribute, then 4 percent 1 percent 5.
-- examples.
Chmoda=rwxfile
And
Chmod777file
The effect is the same
Chmodug=rwx,o=xfile
And
Chmod771file
The effect is the same
If you use chmod4755filename, you can make this program have the permission of root
--
2 the other is chmod followed by a letter followed by a file name
To sum up, when you want to use the chmod command to change permissions, the main types of user identities of files are as follows:
U: the user who owns the file (owner)
G: the group in which the owner belongs
O: others (not owners or owners' groups)
A: each or all (u, g, and o).
The types of file access permissions a user has are as follows:
R: read right
W: write right
X: executive power.
There are several types of file permission configuration behaviors:
+: add permissions
-: delete permissions
Make it the only permission.
-example-
Use the chmod command to change permissions. The following example shows how to use the chmod command to change the permissions of a readme.txt file.
Suppose the following are the initial permission settings for the readme.txt file:
-rw-rw-r-1windawinda398 monthly 1112:04readme.txt
If you are the owner of this file or are logged in as the root user, you can change the permissions of the owner, group, and others. Initially, from the above analysis, it can be seen that the owner and group of the readme.txt file can read and write to the file (rw-), and anyone outside the group can only read the file (r -).
File permissions are a security measure. Whenever others are allowed to read, write, or execute a file, it increases the risk that the file will be tampered with or deleted. As a basic principle, read and write access should be given only to those who really need these files.
In the following example, you want to give everyone permission to write to the readme.txt file, so they can read the file, annotate it, and save the file. This means that the "other people" section of the file permissions must be changed.
At this point, you need to enter at the shell or terminal prompt:
Chmodo+wreadme.txt
The oroomw command parameter tells the system that you want to give others permission to write to the file readme.txt. To see the results, list the details of the file again. At this point, the user access to the file is as follows (with an extra w in column 3):
-rw-rw-rw-1windawinda393 monthly 1112:04readme.txt
Now, everyone can read and write to this file.
To remove read and write permissions for groups and others from readme.txt, use the chmod command to remove both read and write permissions.
The command is as follows:
Chmodgo-rwreadme.txt
Tell the system to delete read and write permissions for groups and others in the file readme.txt by entering the go-rw parameter. The results listed again with the ls-1 command are as follows:
-rw--- 1windawinda39March 1112:04readme.txt
The command to remove all permissions, including everyone's permissions, from the file readme.txt is as follows:
Chmoda-rwxreadme.txt
Now, let's see if you can also use the catreadme.txt command to read this file, and the output it returns should look like this:
Cat:readme.txt:Permissiondenied
Removing all permissions, including your own, will successfully lock this file. However, since this file belongs to the user, you can change its permissions back at any time using the following command. The command is as follows:
Chmodu+rwreadme.txt
Use the command catreadme.txt to see if the file can still be read as the file owner.
Here are a few common examples that can be used in chmod command settings:
Grouw: add write rights to groups
O-rwx: remove all permissions from others
Uzzx: allow the file owner to execute the file
A+rw: allows everyone to read and write to a file
Ug+r: allows owners and groups to read files
G=rx: only group reads and executes are allowed (no writes).
*, describe how to restore the permissions of a group. The command is as follows:
Chmodug+xtigger
Now, if you check with the ls-dl command, only others (others) have been denied access to the directory tigger.
= gorgeous separation line =
Ubuntu changes folder and subfolder permissions
Open the terminal to enter the directory you need to modify
Then execute the following command
Chmod777*-R
All subdirectories and file permissions are changed to 777
Permissions to view linux files: ls-l file name
Permission to view linux folder: ls-ld folder name (directory)
Modify file and folder permissions:
Sudochmod- (for type) × × (owner) × × (group of users) × × (other users)
Commonly used commands to modify permissions:
Sudochmod600 (only the owner has read and write permissions)
Sudochmod644 (owners have read and write permissions, group users only have read permissions)
Sudochmod700 (only the owner has read and write and execute permissions)
Sudochmod666 (everyone has read and write access)
Sudochmod777 (everyone has read and write and execute permissions)
On the Linux system to modify the file permissions of the command is shared here, I hope that the above content can enable you to improve. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!
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.