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

Example Analysis of File permissions and Directory permissions in Linux

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

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the example analysis of file permissions directory permissions in Linux, which is very detailed and has certain reference value. Friends who are interested must finish reading it!

The significance of Directory and File permissions in linux

I. the meaning of file permissions

R: you can read the specific contents of this file

W: you can edit the contents of this file, including adding the details of deleting the file.

X: the file has executable permissions-Note: unlike window, in win, the executable permission of the file is shown through the extension, such as exe, bat, etc., but the executable permission of the file in linux is determined by this x and has nothing to do with the file name.

Second, the significance of directory permissions

R: you can view the complete list of files in this directory.

W: you can make relevant changes to all the files and directories in this directory, that is, you can change the structure list in this directory (this should be paid attention to). The specific rights are as follows:

You can create a new file or directory in this directory

You can delete existing files or directories under this directory (no matter what the permissions of the file are, you should pay special attention to this! )

You can rename and change the location of a file or directory.

X: the directory does not have executable permissions, so the function of x in the directory is to allow other users to enter the directory.

Remind everyone to pay attention to:

There is a problem here is that sometimes when we want to share a file with others (in the same group, or other), after you change the permissions of the file, the other party still can not see it, because others can not enter your user's home directory, there is no x permission by default. If you open the x permission at this time in order to allow him to see the file, others will enter the directory to view the file or modify the file. If this person thinks the file is very good and wants to cp a copy, then he has no permission, thinking that the directory does not have w permissions by default, here we should pay special attention to: it is best not to open w permissions directly, because so that others can change the list under this directory at will (including deletion, deletion is very dangerous). So we can cp a copy of this file into a third-party directory with w permission, and the other party cp from here, so that our home directory will not be affected in any way.

Here is a funny example. A system administrator created an important .txt file. In order to prevent others from attempting to this file, the administrator set the permission to-rex-,. The administrator thought it was foolproof, so he put the file in a directory at random, thinking that even if others saw the file, they couldn't do anything. But if the directory has w permission at this time, then although others can not do anything on the file, but he has permission to delete the file, this is fatal.

Let's introduce the significance of Linux permissions for files and directories.

What permissions mean to a file:

R: the actual contents of this file can be read.

W: you can edit, add or modify the contents of the file (but not delete the file). If you don't have r permission, you can't.

X: this file has permissions to be executed by the system. Can be deleted.

Permission to directory

R:read contents in directory . Indicates permission to read a list of directory structures.

W:modify contents in directory . Indicates that you have permission to change the directory structure list. For example, create new files and directories; delete existing files and directories (regardless of their permissions), rename existing files or directories, and transfer files and directories within the directory

X: access directory . The x of the directory represents whether the user can enter the directory for what is called the working directory.

The above is all the contents of the article "sample Analysis of File permissions and Directory permissions in Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, 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

Development

Wechat

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

12
Report