In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to use the chmod command in Linux". Many people will encounter such a dilemma in the operation of actual cases, 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!
The chmod command is used to change access to files or directories on the linux system. Use it to control access to files or directories. This command has two uses. One is a text setting method that contains letters and operator expressions; the other is a numeric setting method that contains numbers.
The chmod command uses numbers to modify file permissions
In Linux system, the basic permissions of files are composed of 9 characters. Take rwxrw-r-x as an example, we can use numbers to represent each permission. The corresponding relationship between each permission and number is as follows:
R-> 4
W-> 2
X-> 1
Because these nine characters belong to three types of users, each user identity contains three permissions (r, w, x). By adding the numbers corresponding to the three permissions, the final value can be used as the permissions of each user.
In the case of rwxrw-r-x, the right limits for owners, groups, and others are:
Owner = rwx = 4 "2" 1 = 7
Group = rw- = 4: 2 = 6
Others = rmurx = 4: 1 = 5
Therefore, the corresponding permission value for this permission is 765.
The basic format of the chmod command to modify file permissions using numbers is:
[root@localhost ~] # chmod [- R] permission value file name
The-R (uppercase) option means that all files in the subdirectory also modify the set permissions.
For 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 176 Sep 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).
The chmod command uses letters to modify file permissions
Since the basic permissions of a file are three user identities (owner, group, and others) with three permissions (rwx), the chmod command uses u, g, o for three identities, and a for all identities (short for all). In addition, the chmod command still uses r, w, and x to represent read, write, and execute permissions, respectively.
The basic format of the chmod command that modifies file permissions using letters is shown in figure 1.
Figure 1 basic format of chmod command
For 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 upright RWX Magi goblrx .bashrc
[root@localhost ~] # ls-al .bashrc
-rwxr-xr-x. 1 root root 176 Sep 22 2004 .bashrc
For another example, 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 176 Sep 22 2004 .bashrc
[root@localhost ~] # chmod axiw.bashrc
[root@localhost ~] # ls-al .bashrc
-rwxrwxrwx. 1 root root 176 Sep 22 2004 .bashrc
This is the end of the content of "how to use chmod commands in Linux". Thank you for 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: 244
*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.