Orginal artical :http://android.stackexchange.com/questions/5884/is-there-a-way-for-me-to-run-adb-shell-as-root-without-typing-in-su

If I'm understanding your question correctly, you're asking how to get root access automatically when you run adb shell, so that you don't have to go into the shell and type su to execute a command as root on your phone.

This is controlled by a flag in your boot partition, which most custom ROMs have modified to allow root permission by default. If you get dropped to a $ when you use adb shell then you have two permanent options and one temporary one (temporary meaning that it doesn't stick if you reboot):

  1. Flash a ROM that includes the modification
  2. Create a custom boot.img and flash it to your phone
  3. Restart adbd on your device with root permissions

Number 2 is actually not that difficult, but it can be somewhat dangerous if you're careless. There is a wiki article here which explains the process and includes a couple of Perl scripts to help you. These instructions assume a Linux/Unix environment. I have personally used these instructions on Fedora Linux and can tell you that they work, but I do not know about other *nix environments like Macs. I also do not know of any similar Windows instructions, but I could try to track some down if you are on Windows. The exact commands will vary somewhat from phone to phone since different devices use different partition tables.

Generally speaking, though, you need to pull your current boot.img from your phone, unpack it, extract the ramdisk, and find the default.prop file. This is a plaintext file, which you need to open in a text editor and then find the line that contains the value ro.secure. If the line says ro.secure=1 then you need to change it to ro.secure=0. After that you can re-pack the ramdisk and boot.img, then flash it to your phone. Once you reboot, you will be greeted with a # prompt whenever you perform adb shell without having to run su.

Alternatively, if you are using a custom ROM but it doesn't have this modification, you can just unzip the ROM and modify the boot.img that is included with it using the above steps. Then you can zip up the ROM with the newly modified boot.img and flash the zip file as you normally would.

This probably goes without saying, but be careful when doing this. Messing with your boot partition can quite easily wreck your phone and force you to recover via HBoot. I would highly recommend testing Fastboot to makes sure you can use extended Fastboot commands and perform a recovery. This varies a bit based on your model, but most phones have some sort of desktop software that can be run to reflash the phone as well.

The third option is that in many cases it may be possible to restart adbd on your device with root privileges. One possibility is to execute adb root from a PC terminal, although this will not work on all ROM configurations (the ROM must be built as a "userdebug" one). You can also try Chainfire's adbd insecure app. This will not persist across a reboot, so you would need to use either the app or adb root again any time you restarted your phone.

Is there a way for me to run Adb shell as root without typing in 'su'?的更多相关文章

  1. Task ‘run’ not found in root project

    问题现象: Task 'run' not found in root project 'springframework'. 问题原因: 没有在gradle.build文件中添加如下配置, mainCl ...

  2. 500 OOPS: vsftpd: refusing to run with writable anonymous root

    500 OOPS: vsftpd: refusing to run with writable anonymous root 以下就是解决的三个步骤,其中第一步,是我一直没有搞明白的,也是其中的重点: ...

  3. 用户添加到sudoer列表## Allow root to run any commands anywhere root ALL=(ALL) ALL Iron ALL=(ALL) ALL

    将用户添加到sudoer列表 李序锴关注 2017.12.20 15:03:25字数 605阅读 4,067 默认情况下,linux没有将当前用户列入到sudoer列表中(在redhat系列的linu ...

  4. run commands in linux shell using batch file

    adb shell as root after device rooted once device rooted, we must perform "su" before we g ...

  5. 生成ARM汇编

    使用ndk即可生成arm汇编 1.首先写好hello.c 2.编写makefile #ndk根目录 NDK_ROOT=E:\Android\android-ndk-r10b #编译器根目录 TOOLC ...

  6. Get sdcard directory by adb

    解决方案: adb shell echo $EXTERNAL_STORAGE  I am making an application, which pulls files(Saved by andro ...

  7. ndk学习8: 编译动态库

    目录: 手工编译动态库 ndk-build编译动态库(Eclipse环境)   手工编译静态库 老规矩还是先手工操作,知其然并知其所以然   需要用到的核心命令: gcc -g -c -fpic -W ...

  8. ndk学习7: 使用静态库

    目录: 手工编译静态库 ndk-build编译静态库   手工编译静态库 老规矩还是先手工操作,知其然并知其所以然   需要用到的核心命令: gcc –g –c mod1.c mod2.c mod3. ...

  9. NDK学习三: 纯手工编译Hello World

      1.配置环境变量 添加make工具path环境变量: E:\Android\android-ndk-r10b\prebuilt\windows-x86_64\bin     2.编写Hello W ...

随机推荐

  1. jQueryr .on方法解析

    .On() 其实.bind(), .live(), .delegate()都是通过.on()来实现的,.unbind(), .die(), .undelegate(),也是一样的都是通过.off()来 ...

  2. Spark小课堂Week3 FirstSparkApp(RDD开发)

    Spark小课堂Week3 FirstSparkApp 问题:Java有哪些数据结构 大致有如下几种,其中List与Map是最重要的: List Map Set Array Heap Stack Qu ...

  3. Python print语句

    1. 输出字符串 >>> strHello = 'Hello World' >>> print (strHello) Hello World 2. 格式化输出整数 ...

  4. C语言-人狼羊菜问题-最容易看懂的解决方法及代码

    题目描述:农夫需要把狼.羊.菜和自己运到河对岸去,只有农夫能够划船,而且船比较小,除农夫之外每次只能运一种东西,还有一个棘手问题,就是如果没有农夫看着,羊会偷吃菜,狼会吃羊.请考虑一种方法,让农夫能够 ...

  5. PowerDesigner 非数值默认值时会自动增加单引单

    在PowerDesigner中,如果默认值是非数值型的,那么 PowerDesigner 会默认加上单引号 因此我们需要把这个默认的单引号干掉,如果是需要设置字符串默认值的时候,就手工加上 单引号 即 ...

  6. ubuntu find方法

    通用格式:find pathname -options [-print -exec -ok]例子:find / -name filename 再根目录里面搜索文件名为filename的文件find / ...

  7. 通过物理模型生成Java代码

    通过物理模型生成Java代码 软件开发过程中,我们一般是先针对数据库建模,物理建模完成后,生成数据库表,编码阶段的时候我们会针对数据库表生成大量的Javaeban或者是实体类 Powertdesign ...

  8. python logging 日志轮转文件不删除问题

    前言 最近在维护项目的python项目代码,项目使用了 python 的日志模块 logging, 设定了保存的日志数目, 不过没有生效,还要通过contab定时清理数据. 分析 项目使用了 logg ...

  9. SC命令详解

    我们知道在MStools SDK,也就是在Resource Kit有一个很少有人知道的命令行软件,SC.exe,这个软件向所有的Windows NT和Windows 2000要求控制他们的API函数. ...

  10. bnu 4359 无爱编号(规律)

    http://www.bnuoj.com/bnuoj/problem_show.php?pid=4359 [题意]:输入N,表示几位数,0-这个N位数,有多少个满足条件的号码,不满足的情况为出现4,1 ...