首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“`chmod ugo+rwx /`”比“`chmod 777 /`”安全吗?

“`chmod ugo+rwx /`”比“`chmod 777 /`”安全吗?
EN

Unix & Linux用户
提问于 2016-07-18 17:45:22
回答 2查看 21.6K关注 0票数 6

我读过这里chmod -R 777 /是一个非常糟糕的主意,因为它覆盖了文件的权限,并擦除粘性位和setgid之类的东西。

但是,我认为chmod -R ugo+rwx /不会覆盖这些权限,而是添加它们,如果不是已经存在的话,那么它将比前面的命令安全得多。

我说的对吗?或者这些命令基本上是一样的,两者都会摧毁我的系统吗?

我不打算这样做,只是要求一般的文化。

EN

回答 2

Unix & Linux用户

回答已采纳

发布于 2016-07-18 18:08:59

您将从您的系统中删除所有安全性,使其极易受到攻击。由于权限不安全,许多程序将停止运行。在技术上是正确的,它会追加这些权限,而不是过写,这样就可以保留SGID和SUID权限。我有一个旧的Ubuntu机器,我不再需要,所以我想我会测试这个。运行chmod -R ugo+rwx /后,由于/usr/lib/sudo/sudoers.so上的不安全perms,sudo停止工作。ssh停止工作,因为我使用的是rsa键,这也需要严格的权限。我无法在操作系统中重新启动机器,因为sudo坏了,但是电源按钮工作得很好。我很惊讶,因为服务器实际上引导得很好,我可能可以用单用户模式修复它,但我只是要重新安装。所以,为了回答你的问题,不。虽然chmod -R ugo+rwx /在技术上与chmod -R 777 /不同,但它并不安全,因为它们都破坏了您的系统。

票数 10
EN

Unix & Linux用户

发布于 2016-07-18 17:57:56

这些命令并不相同,因为您在符号表示中使用+而不是=,所以您的观察可能是正确的,但最好是查看chmod的手册页。man chmod

.

代码语言:javascript
复制
 SETUID AND SETGID BITS
   chmod clears the set-group-ID bit of a regular file if the file's group ID does not match
   the  user's  effective  group ID or one of the user's supplementary group IDs, unless the
   user has appropriate privileges.  Additional restrictions may cause the  set-user-ID  and
   set-group-ID  bits  of  MODE or RFILE to be ignored.  This behavior depends on the policy
   and functionality of the underlying chmod system call.  When in doubt, check the underly‐
   ing system behavior.

   chmod  preserves  a  directory's  set-user-ID and set-group-ID bits unless you explicitly
   specify otherwise.  You can set or clear the bits with symbolic modes like u+s  and  g-s,
   and you can set (but not clear) the bits with a numeric mode.
票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/296675

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档