Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How linux modifies directory permissions

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

In this article Xiaobian for you to introduce in detail "linux how to modify directory permissions", the content is detailed, the steps are clear, the details are handled properly, I hope this "linux how to modify directory permissions" article can help you solve your doubts, following the editor's ideas slowly in-depth, let's learn new knowledge.

In linux, you can use the chmod command to modify directory permissions. The purpose of this command is to control users' permissions on files. You can use numbers or symbols to change permissions. The syntax is "chmod [- R] permission value directory name".

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to modify directory permissions by linux

Yes, just use the chmod command. The chmod command sets file permissions in two ways, using numbers or symbols to change permissions.

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 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 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 Sep 22 2004. Bashrc read here, this article "linux how to modify directory permissions" article has been introduced, want to grasp the knowledge of this article also need to practice and use in order to understand, if you want to know more related articles, welcome to follow the industry information channel.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report