Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the file permissions of the Linux system

Shulou Source: shulou.com Published: 2022-06-01 21:07:53 10月06日 Update

This article introduces the relevant knowledge of "what are the file permissions of the Linux system?" in the course of the operation of the actual case, 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!

Common permissions

There are three identities in the linux system: owner g: group o: others

These identities have the following permissions for those commonly used in documents:

R: read permission, users can read the contents of the document, such as using cat,more to view

W: write permission, and users can edit the document

X: this directory has permissions that can be executed by the system

Other permissions

In addition to read-write execution permissions, the system also supports mandatory bits (s permissions) and sticky bits (t permissions).

S permission

S permission: set the file to have the permission of the file owner at run time, which is equivalent to temporarily owning the identity of the file owner. The typical file is passwd. If the average user executes the file, the file can get root permission during execution, so that the user's password can be changed.

Ls-al / usr/bin/passwd-rwsr-xr-x 1 pythontab pythontab 32988 2018-03-16 14:25 / usr/bin/passwd

We can set s permissions through character mode: chmod astats filename, or we can set s permissions in absolute mode:

Set s u i d: set the bit before the corresponding permission bit to 4

Set g u i d: set the bit before the corresponding permission bit to 2

Set both: set the bit before the corresponding permission bit to 4-2-6.

Note: when setting the s permission, the file owner and group must first set the corresponding x permission, otherwise the s permission will not really take effect (the chmod command does not perform the necessary integrity check, even if the s permission is set without setting the x permission, chmod will not report an error. When we see rwS when we ls-l, uppercase S indicates that the s permission is not in effect)

T permission

T permission: to delete a document, you do not have to have write access to the document, but you must have write access to the parent directory of the document. In other words, even if you do not have write access to a document, but you have write access to the parent directory of the document, you can delete the document, and if you do not have write access to a directory, you cannot create a document in this directory.

T permission can play this role in how to enable a directory to allow any user to write to a document without allowing the user to delete other people's documents in that directory. T permissions are generally used only on directories, not on documents.

After setting the t permission bit in a directory (such as / home, permission is 1777), any user can create documents in this directory, but can only delete their own documents (except root), which has a protective effect on the user documents in the directory that any user can write.

T permissions can be set through chmod + t filename

This is the end of the content of "what are the file permissions of the Linux system?" thank you for your 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 documents directories files users systems roles contents identities superiors can be passed commonly used owners more patterns knowledge processes practical necessary learned Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Huawei macOS OPPO Reno Shulou Technology