android - 如何使用 chmod 设置权限

标签 android bash shell file-permissions chmod

我最近找到了一种使用 dropbear SSH 服务器在我的 android 设备上维护 root 访问权限的方法,我修改了该服务器以使用 init.d 在启动时以 root 身份运行,这是一个 lil 脚本魔术和我制作的一些配置脚本。想要的话可​​以去看看here ...无论如何,为了实验,我从系统中删除了 su 二进制文件和 Superuser.apk。我设法将它们复制回系统,但我不知道如何为 su 二进制文件设置适当的权限。如果我在另一部获得 root 权限的手机上查看 super 用户应用程序并进行更新,它会显示 -rwsr -sr-x 作为二进制文件的权限。我如何手动设置这些相同的权限以及它们是什么意思?特别是 s 部分。

最佳答案

s 部分是 setuid 位。 Wikipedia :

setuid and setgid (short for "set user ID upon execution" and "set group ID upon execution", respectively) are Unix access rights flags that allow users to run an executable with the permissions of the executable's owner or group respectively and to change behaviour in directories.

该权限字符串表示:

  • 所有者可以读取、写入和执行
  • 文件所在组的用户可以读取和执行
  • 其他用户可以读取和执行
  • 文件设置了setuid

您可以通过运行 chmod 06755/system/bin/su 来设置该特定权限。这是八进制(=“八分之一”,就像十进制是“十分之一”,十六进制是“十六分之一”)编码:

  • setuid 位 (4) 和 setgid 位 (2) = 6
  • 所有者的所有权限 (7)
  • 第(5)组的阅读和执行
  • 为他人阅读和执行 (5)

关于android - 如何使用 chmod 设置权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19581462/

相关文章:

windows - Git Hook 未在 Windows 上运行

linux - 在 bash 脚本中循环调用 api

android - run-as 包 'a.b.c' 未知 - Galaxy S4 Jellybean 或 Android 4.3

android - 我应该像在 sqlite 中一样存储颜色?

linux - 如何将具有单列的文本文件转换为矩阵?

linux weblogic停止脚本pid

bash - 如何在 bash 中使用不可打印的字符作为排序命令的字段分隔符?

android - 检索 RSS 提要并将其显示在 TextView 中

android - 在 LongPress 之后移动事件

bash - kafka-console-producer : command not found