简体   繁体   English

不要删除root用户在其他用户文件夹中创建的文件

[英]do not delete a file created by root user in the other users folder

I have a user called "sam" and the home directory of sam is /home/sam 我有一个名为“ sam”的用户,并且sam的主目录是/ home / sam

Now as a root user i have to keep some files in /home/sam/Desktop directory . 现在,作为root用户,我必须将一些文件保存在/ home / sam / Desktop目录中。 and sam should have only read and execute permission he should not delete that file. 并且sam应该仅具有读取和执行权限,而不应该删除该文件。

not the desktop file will be a soft link of /usr/share/application 不是桌面文件将是/ usr / share / application的软链接

steps i have tried : 我尝试过的步骤:

log in as root cd /home/sam/Desktop echo "test not delete file" > /usr/share/application/abc.txt ln -s /usr/share/application/abc.txt /home/sam/Desktop/abc.txt exit log in as sam rm /home/sam/Desktop/abc.txt Do you want to delete write protected file? 以root用户身份登录cd / home / sam / Desktop echo“测试不删除文件”> /usr/share/application/abc.txt ln -s /usr/share/application/abc.txt / home / sam / Desktop / abc .txt退出,以sam rm /home/sam/Desktop/abc.txt登录。是否要删除写保护的文件? y delete success y删除成功

now how can i prevent it? 现在我该如何预防呢?

使文件不可变:chattr + i /home/sam/Desktop/abc.txt

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 linux如何允许用户读取/写入/删除从根目录创建的特定文件夹中的文件 - linux how to allow user to read/write/delete files created from root in a specific folder 有没有办法阻止不同的用户删除同一共享文件夹中的其他用户的文件(但他们可以创建自己的新文件)? - Is there any way to prevent different users from delete other user's files in the same share folder (but they can create own new files)? 如何删除目标用户使用scp创建的目标文件夹 - How to delete target folder created using scp by target user linux中的其他用户如何授予root用户生成的文件权限? - How to give permission to root user generated file by other user in linux? 如何以编程方式在root用户拥有的文件夹中创建文件 - How to create a file programmatically in a folder owned by root user 将上载的文件作为php的根目录移动到其他用户主文件夹 - move uploaded file to different user home folder as root in php 我可以删除root用户主目录中的Matlab安装文件 - Can I delete the Matlab installation file in root user home directory 如何删除另一个用户创建的共享内存文件? - How to delete a shared memory file created by another user? 如何删除另一个用户使用 C 创建的文件? - how can I delete a file created by another user using C? 用户可以创建文件或文件夹,但限制在 centos-8 中删除 - User can create file or folder but restricted to delete in centos-8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM