Setting appropriate permissions on SU binary 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 &amp; 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 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 &amp; what do they mean?
For setting file permissions, you can use the chmod command. The permissions shown are basically split in 3 parts, each consisting of 3 chars: a triple for the owner, the group, and for "others". Usually, each triple holds definitions for reading, writing, and executing a file; so rwx means "can read, write, and execute", while r-- would say "can only read".

The resulting 9 chars are usually preceded by another one, giving information of the type of the "file": (d)irectory and (l)ink are the most common examples. Again, if no "special condition" matches, a leading - indicates a "normal file".

Based on that, let's take your input: -rwsr-sr-x obviously describes a "normal file" (starting with -), readable (r) by owner, group, and others, writable by owner only, and executable by "others" ­– while owner and group have a s instead the x for execute. This stands for "suid", elevate the caller to the level of the file owner/group.

Taking advantage of the fact permissions can be set "bit-wise" (x=1,w=2,r=4, suid user=4, group=2), after my long "rant" finally the command which should do the trick:

chmod 6774 su


Should set the permissions your question shows. If I "mis-calculated", you've got all information to re-calculate for yourself now :)



Additional hints from the comments:

Instead of calculating the "bitmask", one can also use symbolic names – as Dan Hulme pointed out, and as explained e.g. on the chmod manpage:


defining whom to grant to: (u)ser / (g)roup / (o)thers / (a)ll
defining what to grant: (r)ead / (w)rite / e(x)ecute / (s)uid
defining whether to (+)grant or (-)revoke


So the following two commands should be similar, provided there haven't been other things granted before:

chmod 6774 su
chmod u+rws g+rs o+rx su


The difference becomes clear in case e.g. before "others" had also write permission: while the first command (using a bitmask) sets the permission explicitly to match the "grants" defined (and thus would remove that write permission), the symbolic one "makes a diff" (in the example, it just adds the permissions specified to whatever was there before, so that write permission would not be removed).