In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the format and method of using chmod command under Linux/Ubuntu". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the format and method of using chmod command under Linux/Ubuntu".
The permissions of file calls in the Linux/Ubuntu system are divided into three levels: file owner (u), group (g), and other (o). You can change the permissions of a file with chmod. Chmod is a fairly flexible command, and the permissions of the same file can be modified in a variety of command formats.
Method 1:
Syntax format: chmod [- vR] mode file name
Parameter description:
Mode permission setting string in the format [ugoa] [+-=] [rwx]
U represents the owner of the file
G represents a person who belongs to a group with the owner of this file.
O for other people
A means to include the above three, that is, file owner (u), group (g), and other (o)
+ means to increase permissions
-denotes cancellation of permission
= indicates unique setting permissions
R indicates that you have read permission
W means you have permission to write
X means you have permission to execute.
-v displays the details of permission changes
-R means to make the same permission changes to all files and subdirectories under the current directory
Example:
We want to modify the permissions of the ownlinux file in the current directory to all users who have the permissions to read, write and execute the file. It needs to be used in combination with the sudo command here. If you don't know much about the sudo command, please take a look at the "detailed explanation of the sudo command" on this site.
Ownlinux@server:/var/www$ sudo chmod a+rwx ownlinux
[sudo] password for ownlinux: (enter your password at this time)
Or use the
Ownlinux@server:/var/www$ sudo chmod ugo+rwx ownlinux
[sudo] password for ownlinux: (enter your password at this time)
The command is different, but the effect is the same after execution.
Method 2:
Syntax format: chmod [- vR] [No] file name
Parameter description:
Three digits of No represent the corresponding permissions
-v displays the details of permission changes
-R means to make the same permission changes to all files and subdirectories under the current directory
This approach may be difficult for beginners, but it becomes very easy to change file permissions after learning this method. I believe that through my introduction, you will master a method:)
First, take a look at the corresponding numeric numbers for reading (r), writing (w), and executing (x), as shown in the following figure.
If you remember the number shown above and the corresponding permissions, look down.
As I just said, the [No] parameter is a three-digit number representing the corresponding permissions. From left to right, the first math represents the permissions of the file owner (u), the group (g), and the other (o). The right of each number to the user at that level is the sum of the corresponding numbers of rwx. Maybe you don't quite understand this. I drew a table to help you understand.
As can be seen in the above figure, if all users have the permissions to read, write and execute the file, that is, the permissions of the owner (u) (428), the permissions of the group (g) (4percent 2), and the permissions of other (o) (777). Note: if you do not have read permission, the corresponding number of "r" is "0". The same goes for write (w) and execute (x).
Example:
Using the example of method 1, we want to modify the permissions of the ownlinux file in the current directory to all users who have read (r), write (w), and execute (x) permissions for the file. Review the command format for mode one.
Ownlinux@server:/var/www$ sudo chmod a+rwx ownlinux
[sudo] password for ownlinux: (enter your password at this time)
Command of mode two
Ownlinux@server:/var/www$ sudo chmod 777 ownlinux
[sudo] password for ownlinux: (enter your password at this time)
It can be seen that the format of the command in mode 2 is simple and clear.
If you want to change the permissions of the ownlinux file under the current directory to the owner (u) of the file to have read (r), write (w), and execute (x) permissions for the file, and the group (g) and other (o) users only have read (r) and execute (x) permissions, run the following command:
Ownlinux@server:/var/www$ sudo chmod 755 ownlinux
[sudo] password for ownlinux: (enter your password at this time)
I believe that through my introduction, everyone already has a certain understanding of the command chmod. I think the command style of mode 2 is easy to grasp as soon as you understand it, and the command style of mode 2 is simple and clear.
Thank you for reading, the above is the content of "the format and method of using chmod command under Linux/Ubuntu". After the study of this article, I believe you have a deeper understanding of the format and method of using chmod command under Linux/Ubuntu, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.