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 CentOS File and Directory permissions

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

Share

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

This article will explain in detail the example analysis of CentOS file and directory permissions. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

The environment creates two users

User1 and user2

[root@localhost ~] # useradd user1

[root@localhost ~] # useradd user2

Create two folders

[root@localhost] # mkdir-p / user1 / user2

Open another terminal and switch to su-user1

[root@localhost ~] # su-user1

Create a user2 file under user2

[root@localhost /] # touch / user2/user2

[root@localhost /] # ls-l / user2/user2

-rw-r--r--. 1 root root 0 March 20 01:37 / user2/user2

View permissions

Deleting and moving a file is related to the parent directory, even if the permission is 777, it can not be deleted as long as the parent directory has permission, even if the file itself is 000.

Even if you give him 777 permissions,

[root@localhost /] # ls-l / user2/user2

-rwxr--rwx. 1 root root 0 March 20 01:37 / user2/user2

[user1@localhost user2] $rm-rf user2

Rm: unable to delete "user2": insufficient permissions

[root@localhost /] # ls-ld / user2

Drwxr--rwx. 2 root root 4096 March 20 01:37 / user2

You can move and delete as long as the user2 directory has permission.

User1 executes delete command

[user1@localhost user2] $rm-rf user2

That's it.

This is the end of this article on "sample analysis of CentOS file and directory permissions". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

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