Root Learning for Android

Source: Internet
Author: User

Refer to this article: https://www.zhihu.com/question/21074979

Android kernel is Linux, so Android get root actually and Linux get root permissions is a thing.
You want to get root permissions under Linux is the execution of Sudo or Su, then the system will prompt you to enter the root user's password, the password is correct to get root permissions. Android itself does not want you to get root access, most of the phone factory when there is no SU this program. So if you want to gain root access to Android, the first step is to copy the compiled Su file to the/system/bin or/system/xbin/directory of your Android phone. Let's say you can put Su under the XBin, then you can enter SU on the Android phone's adb shell or the serial port.
After the Linux su to enter the password can root, but the SU in the Android and the SU in Linux is not the same, the SU in Android is not by verifying the password, but to see what your original permissions. This means that if you are root, you can switch to another user via Su, such as Shell,wifi,audio or something. But if you are a user other than root, you can not switch back to root, you will be prompted to permission denied. Also said that using root to run Su is useful, but I do not have root at this time what to do? This involves a different problem.
Generally we enter ls-l under the console of Linux to list all the files ' permissions.
For example:-rwxr-xr-x, people who have used Linux know that r means that the file is readable, W is writable, X is executable,-it means no such permission. The first rwx represents the permissions of the owner of the file, the second rwx represents the rights of the same group as the owner, and the third rwx represents the permissions of the other user on the file. But the following file is quite special.

RWS, its EXECUTE permission flag bit is a s,s represents when any user executes the file with the permission of the owner of the file, the owner of the file is root, the simple point is that no matter who executes the file, he executes as root.
Also said that even if I am not root can also be the root of the execution of the program, then I put an owner is the root of the SU program permission flag location into-rwsr-xr-x, then no matter who executes it, is the root identity execution, SU can successfully execute the successful, After successful execution, I was the root identity.

The problem is clear, you need to copy an owner-root su to the Android phone, and the SU's permission flag position to-rwsr-xr-x. If you can get this thing done, you'll be rooting for a cell phone.
Probably means two lines of code.
cp/data/tmp/su/system/bin/#copy su to/system/partition
Chown root:root su #su的所有者置成root
chmod 4775/system/bin/su #把su置成-rwsr-xr-x

Why Su must be put in/system/bin/or/system/xbin/
Su cannot be placed on the data partition because the data partition specifies that the executable program cannot add s-bits when it is mount. Execute mount in the ADB shell to see:

Root Learning for Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.