简体   繁体   中英

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

Now as a root user i have to keep some files in /home/sam/Desktop directory . and sam should have only read and execute permission he should not delete that file.

not the desktop file will be a soft link of /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? y delete success

now how can i prevent it?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM