首页 > 解决方案 > 为未加密的文件设置密码

问题描述

我想用密码保护一个文件,但我不想加密它。
可能吗?
我正在使用 macOS。

标签: operating-systempassword-protection

解决方案


这是不可能的。您可以做的是限制对该文件的权限,例如:

chmod -rw /path/to/file    # remove Read/Write permissions for every user
chmod ug+rw /path/to/file # grand persmission only to owner (user or group).
chown otherUser:otherGroup /path/to/file

要访问该文件,您需要切换用户上下文,例如通过sudosu


推荐阅读