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. window.onbeforeunload 如果取消, 那么javascript变量会保存

    function confirmQuit1() { if (ischanged) return 'it is changed !! '; else return 'no change .. '; } ...

  2. C++程序员笔试复习概要(一)

    第8章     类和对象的创建 [内容提要] 类和对象 构造函数和析构函数 对象数组与对象指针 静态成员 友元 静态函数 虚函数 [重点与难点] 8.1 类和对象 8.1.1 类的定义 类实质上是用户 ...

  3. select 函数实现 三种拓扑结构 n个客户端的异步通信 (完全图+线性链表+无环图)

    一.这里只介绍简单的三个客户端异步通信(完全图拓扑结构) //建立管道 mkfifo open顺序: cl1 读 , cl2 cl3 向 cl1写 cl2 读 , cl1 cl3 向 cl2写 cl3 ...

  4. oracle中的隐式提交(auto commit)

    通常我们执行sql或pl/sql时,需要我们手工提交.这样才能使所做的更改永久保存到数据库. 但有时即使我们没有在sql或pl/sql中发出commit命令,所做的更改也会被提交.这种提交是在某些特定 ...

  5. Schtasks 命令详解

    管理计划任务 SCHTASKS /parameter [arguments] 描述:     允许管理员创建.删除.查询.更改.运行和中止本地或远程系统上的计划任务. 参数列表:     /Creat ...

  6. Code for the Homework2 改进

    1. 实现了到指定点各个关节的转角计算(多解性),并且所求解满足各个关节的最大角和最小角的限制条件. 2. 对方向向量进行了单位化,保证任意大小的向量都行 #include<iostream&g ...

  7. c#类库中使用Session

    网站开发中,为了保存用户的信息,有时候需要使用session.如果我们在aspx页面中使用Session,只需要Session["key"]=value就可以,获取时使用int u ...

  8. 通过android.provider包查看android系统定义的provider.

    原先的2.2的android源码已经不是那么容易找到了,我稍稍搜索了下找到了一两个没速度的死链就失去了兴趣.不过还好忽然发现在android.provider包下包含了常见的provider的使用方法 ...

  9. 1037: [ZJOI2008]生日聚会Party - BZOJ

    Description 今天是hidadz小朋友的生日,她邀请了许多朋友来参加她的生日party. hidadz带着朋友们来到花园中,打算坐成一排玩游戏.为了游戏不至于无聊,就座的方案应满足如下条件: ...

  10. [转]LINQ操作数据库

    查询表达式(LINQ)简介 C#3.0新语特性和改进,这些新特性在我们编写程序时为我们提供了非常大的帮助.从这篇开始,我们开始一起来探讨LINQ. LINQ是Language Integrated Q ...