有时,有些文件比较重要,为了防止rm -rf强制删除文件带来的麻烦。可以使用命令将文件保护起来(Linux即便是sudo,也不能直接删除保护起来的文件)。

由于Mac是基于Unix的系统,和Linux的命令使用上某种程度上还是有一定的区别的。

保护文件主要是改变文件的flags

1. 加上flags

Mac:   

[sudo] chflags uchg filename

用sudo还是可以删除的

Linux:

[sudo] chattr +i filename

用sudo删除不了

2. 去除flags

Mac:

[sudo] chflags nouchg filename

Linux:

[sudo] chattr -i filename


3. 查看flags

Mac:

ls -lO filename

Linux:

lsattr filename

912sy.com download resources are from the network, only for learning and reference use, the copyright belongs to the original author, do not use for commercial purposes, please remove yourself within 24 hours after downloading.
If the content published on this site inadvertently violates your rights and interests, please contact us and the site will be deleted within one business day.If you encounter any problems please contact customer service QQ:2385367137
912sy " Problems with Mac and Linux files not being deleted