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 does linux change folder permissions

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

Share

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

In this article, the editor introduces in detail "how to change folder permissions in linux". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to change folder permissions in linux" can help you solve your doubts.

Linux can change folder permissions. In linux, you can use the chmod command to change the permissions of a folder (directory); this command controls the user's permissions on a file or directory, with the syntax "chmod [who] [+ |-| =] [mode] directory name" or "chmod permission value directory name".

The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

Linux can change folder (directory) permissions.

In the Linux system, users set file permissions to control that other users can not access and modify. However, in system applications, it is sometimes necessary to let other users use a file or directory that they cannot access, so it is necessary to reset the permissions of the file. The command is the chmod command.

Linux chmod command: changing directory permissions

The Linux chmod (English spelling: change mode) command is a command that controls the user's permissions on files (directories).

Not everyone can change the access rights of files and directories, only the owners of files and directories have the right to modify their permissions, in addition, the superuser can set permissions on all files or directories.

The chmod command is used as follows:

Chmod [who] [+ |-| =] [mode] file (directory) name

The Operand who in the chmod command can be any of the letters in Table 1 or a combination of them.

Table 1:chmod Command who option description u stands for "user (user)", that is, the owner of the file or directory. G stands for "group users", that is, all users who have the same group ID as the file owner. O means "others users" a means "all users", which is the default value of the system.

The chmod command operation symbol description is shown in Table 2.

Table 2:chmod command action symbol description option description + add a permission-cancel a permission = grant a given permission and cancel all other permissions (if any)

The permissions represented by mode can be any combination of the letters in Table 3.

Table 5:chmod command mode option description option r readable w writable x executable X append x attribute s when the target file is executable to some users or the target file is a directory set the owner or group ID of the process as the file owner when the file is executed. The user ID bit of the file is set by mode "Utility", and the group ID bit is set by "Groups". T save the text of the program to the exchange device u has the same permissions as the file owner g and users in the same group as the file owner have the same permissions as other users

Multiple permissions can be given on a command line, separated by commas. For example, chmod example example, this command will give the same group and other users read access to the file example.

Permissions for files and directories can also be represented in octal numeric mode. First understand the meaning of numeric attributes: 0 indicates no permissions, 1 indicates executable permissions, 2 indicates writable permissions, 4 indicates readable permissions, and then adds them. So the format of the numeric attribute should be 3 octets from 0 to 7, in the order of (u) (g) (o). For example, if you want the owner of a file to have "read / write" permissions, you need to put 4 (readable) + 2 (writable) = 6 (read / write).

The basic format of the chmod command to modify file permissions using numbers is:

Chmod [- R] permission value file (directory) 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).

After reading this, the article "how to change folder permissions in linux" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about 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