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 ...
随机推荐
- 我的第一个canvas的作品:漫画对白编辑器
背景:一直都对canvas挺有有兴趣的,之前刚刚看了<HTML5 CANVAS基础教程>,写了篇读书笔记. 起因:老婆发来一张最近比较热的漫画图(友谊的小船说翻就翻什么的).这种漫画,经常 ...
- 《HTML5 CANVAS基础教程》读书笔记
一.HTML5简介 1.HTML5新特性 1)结构元素:section,header,hgroup,footer,nav,article,aside, 2)内容元素:figure,figcaption ...
- Eclipse查看源码乱码问题
在同一个工作区下,依赖的Jar包如果既有GBK编码,又有UTF-8编码,就会出现的问题. 常规解决方法 1.切换工作区编码.麻烦,效率低. 2.设置Jar包编码,只有Eclipse4.2支持,4.0以 ...
- Spark Streaming揭秘 Day28 在集成开发环境中详解Spark Streaming的运行日志内幕
Spark Streaming揭秘 Day28 在集成开发环境中详解Spark Streaming的运行日志内幕 今天会逐行解析一下SparkStreaming运行的日志,运行的是WordCountO ...
- 面试知识:操作系统、计算机网络、设计模式、Linux编程,数据结构总结
基础篇:操作系统.计算机网络.设计模式 一:操作系统 1. 进程的有哪几种状态,状态转换图,及导致转换的事件. 2. 进程与线程的区别. 3. 进程通信的几种方式. 4. 线程同步几种方式.(一定要会 ...
- 实现Linux select IO复用C/S服务器代码
已在ubuntu 下验证可用 服务器端 #include<stdio.h>#include<unistd.h>#include<stdlib.h>#include& ...
- AJAX 原理(转摘)
在写这篇文章之前,曾经写过一篇关于AJAX技术的随笔,不过涉及到的方面很窄,对AJAX技术的背景.原理.优缺点等各个方面都很少涉及null.这次写这篇文章的背景是因为公司需要对内部程序员做一个培训.项 ...
- PHP+MYSQL 出现乱码的解决方法
PHP+MYSQL 出现乱码的解决方法 使用PHP+MYSQL时遇到过字符乱问题,解决方法: 在mysql_connect后面加一句SET NAMES UTF8,即可使得UTF8的数据库消除乱码,对于 ...
- Jetty 与 Tomcat 比较,及性能分析
主流java的web容器,主要是Tomcat, jboss, jetty, resin.由于以前我们主要用的是jboss4.0.5,但jbosse用的servlet容器是tomcat5.5,所以只进行 ...
- 简单3d RPG游戏 之 004 攻击(二)
人物和怪物的攻击都有CD冷却,在PlayerAttack脚本中添加成员 //冷却倒计时 public float attackTimer; //CD冷却时间 public float coolDown ...