Home  >  Article  >  Operation and Maintenance  >  What is the command to modify file permissions in Linux?

What is the command to modify file permissions in Linux?

WBOY
WBOYOriginal
2021-12-24 11:37:1745861browse

The command to modify file permissions in Linux is "chmod". The chmod command is used to change the permissions of files and directories. The setting method uses text or numerical codes. The syntax is "chmod [-R] permission value file name" or "chmod [-R] [u,g,o,a][ ,-,=][r,w,x]".

What is the command to modify file permissions in Linux?

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

What is the command to modify file permissions in Linux

If you want to change the permissions of a file, only the administrator root and the owner can modify it

There are two ways to set Linux file attributes, one is numbers and the other is symbols.

There are nine basic permissions for Linux files. The three identities of owner/group/others each have their own read/write/execute permissions.

We can use numbers to represent each permission. The score comparison table for each permission is as follows:

  • r:4

  • w:2

  • x:1

Three permissions for each identity (owner/group/others) (r/w/ x) The score needs to be accumulated. For example, when the permission is: [-rwxrwx---] the score is:

owner = rwx = 4 2 1 = 7group = rwx = 4 2 1 = 7others= -- - = 0 0 0 = 0

So when we set the permission changes, the permission number of the file will be 770! The syntax of the chmod command to change permissions is as follows:

chmod [-R] xyz file or directory
xyz: It is the numeric type permission attribute just mentioned, which is the addition of the rwx attribute values. -R: Perform recursive and continuous changes, that is, all files in the sub-directory will be changed

② Symbol type changes file permissions

We can use u, g, o to represent the authority of the three identities!

In addition, a represents all, that is, all identities! Then the read and write permissions can be written as r, w, x! That is to say, you can use the following method to look at it:

What is the command to modify file permissions in Linux?

If we need to set the file permissions to -rwxr-xr--, we can use chmod u=rwx,g=rx ,o=r file name to set.

Example:

What is the command to modify file permissions in Linux?

What is the command to modify file permissions in Linux?

Note: If a directory has write permission, other users will not be able to access the files in this directory. It can also be deleted.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of What is the command to modify file permissions in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn