[Android advanced] temporarily uninstall and restore the root function, androidroot

Source: Internet
Author: User

[Android advanced] temporarily uninstall and restore the root function, androidroot

[Preface] Why is there such a demand?

Q: first, why do you want root?

A: Only root users can have control, and many things can be involved, such as deleting and deleting rogue software and using agents and software for automatic installation;

Q: Why do I need to delete the root user?

A: Sometimes some tools cannot be executed on the root machine, but these functions are also very attractive to us, such as mobile phone punching and other awesome functions; if you want to use these features and occasionally root them, congratulations, you can do it in the following way;

 

Article 1 Preparation 1.1 root permissions required

As for how to obtain the root, this is the most basic. Many Baidu tools have the one-click root function, which is skipped 10 thousand words;

 

1.2 terminal tools used

We recommend using Better Terminal Emulator Pro, which is free and easy to use;

The reference address is as follows (Baidu mobile assistant can search for it ):

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 required knowledge 1.3.1 about mount

By default, the system partitions after startup are read-only, so even if your mobile phone is already root, what you see during terminal operations is read-only and cannot be modified, you need to re-mount the disk once. The core script is as follows:

mount -o remount,rw /emmc@android /system

 

1.3.2 executable permissions

In linux, various permissions of a program are set through permissions. The core idea is: The read permission value is 4, The Write Permission value is 2, and the execution permission value is 1, set the appropriate permission value. For example, if you want to read, write, and execute the required permissions, 4 + 2 + 1 = 7;

Permission group: A File Permission in linux is divided into three parts: the owner's permission has the permissions of the group and the permissions of others, the three parts are sequentially combined with three octal arrays, so the permission bit settings generally look like 777, 755, that is, everyone can read and write executable and owner can read and write executable, everyone in the group that owns the file can read and execute, and others can read and execute;

The suid and guid are set here, so the entire permission bit is changed to 6755. The first six let the common user feel that the root user is executing the su;

chmod 6755 /system/xbin/su

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

You can also search for the suid guid keyword.

 

2. Action 2.1 view partition information

Open the Super Terminal and enter the mount command to check which partition is mounted to the/system directory. My system is mounted to/emmc @ android to/system. For details, refer:

If you want to use it, enter mount to view the path of your disk partition;

2.2 view the su path

Generally, the su path is:

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

The subsequent assumptions are all under the Common/system/xbin/su path;

2.3 prepare to write the script 2.3.1 back up the original su program broot. sh
#!/system/bin/sh/system/xbin/su -c "mount -o remount,rw /emmc@android /system"/system/xbin/su -c "cp /system/xbin/su /system/su"/system/xbin/su -c "mount -o remount,ro /emmc@android /system"

This script can be executed once, or backed up using Root Explorer!

 

2.3.2 get the root program groot. sh
#!/system/bin/sh/system/su -c "mount -o remount,rw /emmc@android /system"/system/su -c "cp /system/su /system/xbin/su"/system/su -c "chmod 6755 /system/xbin/su"/system/su -c "mount -o remount,ro /emmc@android /system"

The principle is to use the previously backed up su to perform the following steps:

  • Remount the system partition to readable and writable;
  • Copy the backup su to the xbin directory.
  • Set appropriate permissions;
  • Remount the partition in read-only mode;

 

2.3.3 Delete the root program droot. sh

Note that you must first refer to the 2.3.1 script to back up the su to the/system/su directory before executing this program. Otherwise, you will be at your own risk if you do not have root;

#!/system/bin/sh/system/su -c "mount -o remount,rw /emmc@android /system"/system/su -c "mv /system/xbin/su /system/xbin/su.bak"/system/su -c "mount -o remount,ro /emmc@android /system"

The principle is to use the previously backed up su to perform the following steps:

  • Remount the system partition to readable and writable;
  • Rename su under xbin to su. bak;
  • Remount the partition in read-only mode;

 

Trigger the 3.1 download Tool

The BASIC script has been written. Please download it here :)

Http://yunpan.cn/cfwmQui82UXZt (extract code: c7a3)

 

3.2 execution instance

Detailed steps are as follows:

Sh broot. sh # backup suls-al/system/su # Check the backup result sh droot. sh # Delete su and remove the root permission. Be careful !!! Make sure the backup is successful !!! Su # Check whether the removal is successful. If not found is displayed, the removal is successful. su groot. sh # recover the su and restore the root permission. Congratulations :) su # Check whether the recovery is successful. If no error is reported during execution, the program '#' At the prompt indicates that the operation is successful. exit # exit the root mode.

There are pictures and truth !!!

 

[Test Model] Red Rice Note Unicom edition, hm note 1 W;

Welcome to the discussion :)

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.