Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to modify file permissions by linux

Shulou Source: shulou.com Published: 2022-05-31 16:58:49 09月27日 Update

This article introduces the relevant knowledge of "how to modify file permissions in linux". In the operation of actual cases, many people will encounter such a dilemma, 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 command for linux to modify file permissions is "chmod", and the chmod command is used to change the permissions of files and directories. The setting method is text or numeric code, and the syntax is "chmod [- R] permission value file name" or "chmod [- R] [ujime gjinomo a] [, -, =] [rje WJ x]".

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

What is the command for linux to modify file permissions

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 the properties of a Linux file, one is a number, the other is a symbol.

There are nine basic permissions for Linux files, and each of the three owner/group/others identities has its 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

The three r/w/x scores for each owner/group/others need to be accumulated, for example, when the permission is: [- rwxrwx---] the score is:

Owner = rwx = 4 "2" 1 = 7group = rwx = 4 "2" 1 = 7 others =-= 0 "0" 0

So when we set the permission change, the permission number of the file is 770! The syntax for the directive chmod to change permissions is as follows:

Chmod [- R] xyz file or directory

Xyz: the permission attribute of the numeric type just mentioned, which is the sum of the values of the rwx attribute. -R: make continuous recursive changes, that is, all files in the subdirectory will change.

② symbol type changes file permissions

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

In addition, a stands for all, that is, the full identity! Then read and write permissions can be written as r, w, x! That is, you can look at it in the following way:

If we need to set the file permissions to-rwxr-xr--, we can set them using the file name of chmod uplirwx journal gendrx journal oinitir.

Example:

Note: if a directory has write permission, other users can also delete files in this directory.

This is the end of the content of "how to modify file permissions 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!

Tags: Permissions files numbers directories identities representatives scores commands attributes content that is file names methods more knowledge symbols types grammar utility learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info Shulou Technology Docker MariaDB