brew cleanup: Error: Permission denied @ apply2files

issues

修复方式

# 针对/usr/local目录下的所有内容,首先更改own为[所有者][:用户组],这里为admin,原来有staff和wheel。
sudo chown -R $(whoami):admin /usr/local/* \
&& sudo chmod -R g+rwx /usr/local/*
brew list | xargs brew reinstall

另外也可以这样

# 这个命令主要是将homebrew软件目录及其所有子目录和文件的拥有者改为当前用户。但需注意如果没有安装brew,或者环境中的PATH变量没有包括brew,那么最后的部分就会出错。然后系统就挂了。还是上面的🔐一些
sudo chown -R $(whoami) $(brew --prefix)/*

chmod语法

chmod [-cfvR] [--help] [--version] mode file...
#下面命令是chmod 从mode开始  mode =  [{ugoa}{+-=}{rwx}]
chmod [{ugoa}{+-=}{rwx}] [文件夹或目录]

参数说明:
参数:

-c : 若该文件权限确实已经更改,才显示其更改动作
-f : 若该文件权限无法被更改也不要显示错误讯息
-v : 显示权限变更的详细资料
-R : 对目前目录下的所有文件与子目录进行相同的权限变更(即以递回的方式逐个变更)
–help : 显示辅助说明(前面是两个- -)
–version : 显示版本

mode : 权限设定字串
mode参数含义:
u 表示该文件的拥有者
g 表示与该文件的拥有者属于同一个群体(group)者
o 表示其他以外的人
a 表示这三者皆是
+表示增加权限
-表示取消权限
= 表示唯一设定权限(不管之前的权限是什么,按照当前设置的权限处理)
r 表示可读取
w 表示可写入
x 表示可执行(可执行并不是)
X 表示只有当该文件是个子目录或者该文件已经被设定过为可执行。


staff和wheel

所有的用户都属于 staff 组,

只有具有管理员性质的用户位于 wheel 组中。

wheel 是一个特殊的用户组,该组的用户可以使用 su 切换到 root,而 staff 组是所有普通用户的集合。

The wheel group is used to control those people that can su to the root user (though this is made irrelevant by the sudo command).

All of the users on your system will be in the staff group, so by changing group ownership of files to staff the group permissions will apply to all users. All of the administrators on your system will be in the wheel group, so by changing group ownership of the files to wheel group permissions will apply to all of the administrators, global permissions will apply to any other users.

My advice is that, except for files that you have created, you leave the group ownership and permissions alone. Unix is very particular about file ownership and permissions in certain areas and changing them only leads to trouble.

Unix/Linux用户nobody

1、Windows系统在安装后会自动建立一些用户帐户,在Linux系统中同样有一些用户帐户是在系统安装后就有的,就像Windows系统中的内置帐户一样。

2、它们是用来完成特定任务的,比如nobody和ftp等,我们访问 www.php-note.com 的网页程序时,官网的服务器就是让客户以 nobody 身份登录的(相当于Windows系统中的匿名帐户);我们匿名访问ftp时,会用到用户ftp或nobody。

3、首先,nobody是一个普通用户,非特权用户。 使用nobody用户名的’目的’是,使任何人都可以登录系统,但是其 UID 和 GID 不提供任何特权,即该uid和gid只能访问人人皆可读写的文件。

4、其次,许多系统中都按惯例地默认创建一个nobody,尽量’限制它的权限至最小’,当服务器向外服务时,可能会让client以nobody的身份登录。

5、nobody就是一个普通账户,因为默认登录shell是 ‘/sbin/nologin’,所以这个用户是无法直接登录系统的,也就是黑客很难通过漏洞连接到你的服务器来做破坏。此外这个用户的权限也给配置的很低。因此有比较高的安全性。一切都只给最低权限。这就是nobody存在的意义。

Leave a Reply

Your email address will not be published. Required fields are marked *

lWoHvYe 无悔,专一