"Android Advanced" Dynamic install and remove root feature

Source: Internet
Author: User
Tags bit set

Why is there a need for "preface"?

Q: First of all, why do you want root?

A: Root to have control, but also to toss a lot of things, such as: Delete the Rogue software, using agents, software automatic installation, etc.;

Q: Then why do you need to delete root?

A: Sometimes some tools on the root of the machine can not be executed, but these features are also very attractive to us, such as: mobile phone clock ah and so on, if you want to use these features, but also want to root occasionally, then congratulations, you can be done in the following ways;

Prepare for chapter 1.1 to have root privileges

As to how to get root, this is the most basic, Baidu a lot of tools have a key root function; Here is a little over 10,000 words;

1.2 Use of terminal tools

Recommended better Terminal Emulator Pro, free and easy to use;

The reference address is as follows (Baidu mobile phone assistant search on the line):

http://shouji.baidu.com/soft/item?docid=5667996&from=&f=search_app_better%20terminal %20emulator%20pro%40listsp_1_title%401%40header_all_input_btn_search

1.3 Essential Knowledge 1.3.1 about Mount

The default boot after the system partition is read-only, so even if your phone is root, through the terminal operation, see is also read-only, can not be modified, then need to be re-mounted, mainly to be mounted to read and write, the core script is as follows:

Mount REMOUNT,RW /[email protected]/system

1.3.2 About executable Permissions

In short, the Linux perspective of a program's various permissions are set by the permission bit, the core idea is: Read the permission value is 4, write permission value is 2, execute the permission value is 1, what kind of permission is required, then set the appropriate permission value on the line, for example you want to read can write executable, then is 4+2+1=7;

Permissions group, Linux a file permissions are divided into 3 parts, namely: The owner of the rights to have the rights of the Group of other people's rights, three parts in turn with 3 8 in the array and up, so the general permission bit set to look like 777, 755 such son, is all readable writable executable and The owner can read and write executable, the owner of the group that owns the file can be read executable, other people can read executable;

Here an extra set of suid and GUIDs, so the entire permission bit into 6755, the previous 6 let ordinary users perform su when the feeling is root in the same way;

chmod 6755 /system/xbin/su

Detailed can refer to: http://blog.chinaunix.net/uid-26642180-id-3378119.html

You can also search: suid GUID keyword

Two Action article 2.1 viewing the partitioning situation

Open HyperTerminal, enter the Mount command to see which partition is currently attached to the/system directory, my system is mounted /[email protected] to/system, refer to:

To use, enter mount to view your disk partition path;

2.2 Viewing the SU path to be found

The path to the general Su location is:

/system/xbin/su/system/bin/su

The subsequent assumptions are all under the general/SYSTEM/XBIN/SU path;

2.3 Prepare to write script 2.3.1 back up the original SU program broot.sh
#!/system/bin/sh/system/xbin/su"mount-o remount,rw/[email protected]/system "/system/xbin/su"cp/system/xbin/su/system/su"/system/xbin/su  "mount-o remount,ro/[email protected]/system"

This script is usually executed once, or it can be backed up by root Explorer!

2.3.2 Gets the root program groot.sh
#!/system/bin/sh/system/su"mount-o remount,rw/[email protected]/system" /system/su"cp/system/su/system/xbin/su"/system/su"  chmod 6755/system/xbin/su"/system/su"mount-o Remount,ro/[ Email protected]/system"

The implementation principle is to use the above backed up Su, to perform the following steps:

    • Re-mount the system partition as readable and writable;
    • Copy backup of Su to XBin directory
    • Set the appropriate permissions;
    • Re-mount the partition to read-only mode;

2.3.3 Removing the root program droot.sh

Special note, you must refer to the 2.3.1 script backup su to the/SYSTEM/SU directory, and then to execute this program, or no root consequences of self-oh;

#!/system/bin/sh/system/su"mount-o remount,rw/[email protected]/system" /system/su"mv/system/xbin/su/system/xbin/su.bak"/system/su " mount-o remount,ro/[email protected]/system "

The implementation principle is to use the above backed up Su, to perform the following steps:

    • Re-mount the system partition as readable and writable;
    • The SU under the XBin is renamed to Su.bak;
    • Re-mount the partition to read-only mode;

Three free ride 3.1 download tool

The basic scripts are all written, come here to download it:)

Http://yunpan.cn/cfwmQui82UXZt (Extract code: C7A3)

3.2 Execution Examples

Follow the steps below:

sh broot. SH # backup Su ls -al/system/su  # Check the backup result sh droot. SH # Remove Su, remove root privileges, especially be careful!!! Make sure the front backup is successful!!!  su  # checks whether the removal was successful, and a not found indicates that the removal was successful;Su Groot. SH # restore Su, restore root privileges, congratulations:) su ' # ' exit # Quit root mode

There is a picture of the truth!!!

"Test Model" Red Rice note unicom version, HM note 1W;

You are welcome to exchange:)

"Android Advanced" Dynamic install and remove root feature

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.