让 root 用户不能直接删除文件的方法 - ○白子○ 的Blog

让 root 用户不能直接删除文件的方法

[ 2009-08-30 20:21:52 | Author: seaboat ]
Font Size: Large | Medium | Small
有时候为了加强对文件的保护,让 root 用户也不能直接删除某些文件。
chattr 命令给文件设置属性,即可实现以上目标。

例:
# touch test
# chattr +i test
# man chattr
# rm -f test
rm: cannot remove `.htaccess': Operation not permitted
root:~# echo $?
1


若要恢复,只需把命令中的 + 号变成 - 号:
# chattr -i test
# rm test
# echo $?
0


若要查看文件属性,用 lsattr 命令
# lsattr test
----i-------- test


以上方法,对 cp,mkdir, mv, chmod, chown 等命令同样适用。
Comments Feed Comments Feed: http://www6.webng.com/seaboat/feed.asp?q=comment&id=755

There is no comment on this article.

Post Comment
Smilies
[smile] [confused] [cool] [cry]
[eek] [angry] [wink] [sweat]
[lol] [stun] [razz] [redface]
[rolleyes] [sad] [yes] [no]
[heart] [star] [music] [idea]
Enable UBB Codes
Auto Convert URL
Show Smilies
Hidden Comment
Username:   Password: