[英]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.