Is there a way for me to run Adb shell as root without typing in 'su'?
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):
- Flash a ROM that includes the modification
- Create a custom boot.img and flash it to your phone
- 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'?的更多相关文章
- Task ‘run’ not found in root project
问题现象: Task 'run' not found in root project 'springframework'. 问题原因: 没有在gradle.build文件中添加如下配置, mainCl ...
- 500 OOPS: vsftpd: refusing to run with writable anonymous root
500 OOPS: vsftpd: refusing to run with writable anonymous root 以下就是解决的三个步骤,其中第一步,是我一直没有搞明白的,也是其中的重点: ...
- 用户添加到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 ...
- 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 ...
- 生成ARM汇编
使用ndk即可生成arm汇编 1.首先写好hello.c 2.编写makefile #ndk根目录 NDK_ROOT=E:\Android\android-ndk-r10b #编译器根目录 TOOLC ...
- Get sdcard directory by adb
解决方案: adb shell echo $EXTERNAL_STORAGE I am making an application, which pulls files(Saved by andro ...
- ndk学习8: 编译动态库
目录: 手工编译动态库 ndk-build编译动态库(Eclipse环境) 手工编译静态库 老规矩还是先手工操作,知其然并知其所以然 需要用到的核心命令: gcc -g -c -fpic -W ...
- ndk学习7: 使用静态库
目录: 手工编译静态库 ndk-build编译静态库 手工编译静态库 老规矩还是先手工操作,知其然并知其所以然 需要用到的核心命令: gcc –g –c mod1.c mod2.c mod3. ...
- NDK学习三: 纯手工编译Hello World
1.配置环境变量 添加make工具path环境变量: E:\Android\android-ndk-r10b\prebuilt\windows-x86_64\bin 2.编写Hello W ...
随机推荐
- html5 全屏滚动活动页学习
先看几个具体的实例: 1.腾讯娱乐:http://ent.qq.com/zt2014/qqent/h5.htm?from=groupmessage&isappinstalled=0 2.苏宁互 ...
- C#网络通信
Server: using System.Net; using System.Net.Sockets; using System; using System.Collections.Generic; ...
- HTML 背景图片自适应
CSS body.loginpage { background-image: url(../images/background-image.jpg); background-size:cover; } ...
- 1.2 XmlBeanFactory的实例化
源代码分析,是一件既痛苦又快乐的事情,看别人写的代码是通过的,但当你能够看明白的时候,相信快乐也会随之而来,为了减少痛苦,更快的带来快乐, 本文以spring框架的XmlBeanFactory为入手点 ...
- js常识
btnDelAll.Attributes.Add("onclick", "<script lunguage='javascript'>return windo ...
- BZOJ 1710: [Usaco2007 Open]Cheappal 廉价回文
Description 为了跟踪所有的牛,农夫JOHN在农场上装了一套自动系统. 他给了每一个头牛一个电子牌号 当牛走过这个系统时,牛的名字将被自动读入. 每一头牛的电子名字是一个长度为M (1 &l ...
- Maven Source jar
http://blog.csdn.net/symgdwyh/article/details/4407945
- 在NEXUS中加入自己定义的第三方PROXIES代理库
就是要等会耐心,更新好之后,才能在PUBLIC库里进行操作. 下图是JBOSS的
- IText 生成横向的doc文档
IText生成doc文档需要三个包:iTextAsian.jar,iText-rtf-2.1.4.jar,iText-2.1.4.jar 亲测无误,代码如下: import com.lowagie.t ...
- iOS开发的小技巧(断点打印)
iOS开发中我们会碰到这样的需求:打印沙盒目录,打印对象信息,对象信息可以通过断点查看,有时候对象属性繁多时看起来又比较麻烦. 今天学到一个比较实用的方法: 在运行时打一个断点,当程序停在这个断点后, ...