In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you linux how to modify file permissions, I hope you have something to gain after reading this article, let's discuss it together!
In linux, you can use the chmod command to modify file permissions, which are commands that control users' permissions on files, which can be specified using absolute mode (octal numeric mode) or symbolic mode; syntax "chmod [- R] permission value file name".
The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
In linux, you can use the chmod command to modify file permissions.
The 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.
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-- > 4w-- > 2x-- > 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 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).
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 the following figure.
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 uprirwx root@localhost. [bashrc] # 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 176Sep 22 2004. Bashrc [root@localhost ~] # chmod axiw. Bashrc [root@localhost] # ls-al. Bashrc-rwxrwxrwx. 1 root root 2004 Sep 22 2004. Bashrc has read this article, I believe you have some understanding of "how to modify file permissions in linux". If you want to know more about it, please follow the industry information channel. Thank you for reading!
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.