How to set permissions using chmod
The s part is the setuid
bit. 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.
That permission string means:
- the owner can read, write, and execute
- users in the file's group can read and execute
- other users can read and execute
- the file has setuid set
You can set that specific permission by running chmod 06755 /system/bin/su
. That's the octal (= "out of eight", like decimal is "out of ten" and hexadecimal is "out of sixteen") encoding for:
- the setuid bit (4) and setgid bit (2) = 6
- all permissions for the owner (7)
- read and execute for group (5)
- read and execute for others (5)
Comments
-
Geofferey over 3 years
I recently found a way to maintain root access on my android device using a dropbear SSH server that I modified to run at boot as root using init.d, a lil scripting magic & some config scripts I made. If you want you can check it out here... Anyways for an experiment I removed the su binary and Superuser.apk from the system. I've managed to get them copied back to the system, but I don't know how to set the appropriate permissions for the su binary. If I look in Super User app on another rooted phone and go to update, it shows
-rwsr -sr-x
as the permissions on the binary. How can I set these same permission manually & what do they mean? Specifically the s part. -
Geofferey over 10 yearsSo if the s flag is set then it runs the executable as the user its owned by?
-
Christian Ternus over 10 yearsYup, exactly. That's the whole point of su -- you need it to become root, so it needs to be able to, well, become root.
-
Geofferey over 10 yearsCool, that got me up & running. Thanks for the help mate, appreciate it a lot. I learn better by asking questions.
-
Christian Ternus over 10 yearsNot a problem at all. Best of luck.
-
Christian Ternus over 10 years@Geofferey I noticed you were trying to edit this and people kept rejecting your edits. I looked it up and you were right -- what I proposed will also work, but it looks like
06755
is more correct on Android as opposed to desktop Linux systems. I've edited the post. -
dash17291 about 8 yearsWhat is that leading zero before the other four digits (6775)?