有没有办法让我以root身份运行adb shell而无需打字“su”? -- adb 领域 和 root-access 领域 android 相关 的问题

Is there a way for me to run Adb shell as root without typing in 'su'?




有没有办法让我以root身份运行adb shell而无需键入 su ?我希望能够在没有进入shell的情况下获得root访问权限。


Is there a way for me to run Adb shell as root without typing in su? I want to be able to have root access without going into the shell.




如果我正确地了解你的问题,你会在运行 adb shell 时,您如何自动获取root访问权限,以便您不必进入shell和类型<代码> su 以在手机上以root执行命令。

这由引导分区中的标志控制,大多数自定义ROM已修改以允许默认情况下允许root权限。如果您删除到 $ 时,请使用 adb shell 然后,您有两个永久选项,一个临时选项(临时含义,如果您重新启动,它不会粘贴它):< / p>

  1. 闪存包含修改
  2. 的ROM
  3. 创建一个自定义boot.img并将其闪存到手机
  4. 用root权限
  5. 重新启动 abcdefghijklmnadbd

2实际上不是那么困难,但如果你粗心,它可能会有些危险。有一个wiki文章 这解释了这个过程并包括一对夫妇Perl脚本可以帮助您。这些指令假设Linux / UNIX环境。我亲自在Fedora Linux上使用了这些指示,并可以告诉您他们工作,但我不了解其他* NIX环境,如Mac。我也不知道任何类似的Windows说明,但如果您在Windows上,我可以尝试跟踪一些。由于不同的设备使用不同的分区表,确切的命令将稍微从手机到手机到手机。

一般来说,您需要从手机中提取您当前的boot.img,解压缩它,提取ramdisk,找到 default.prop 文件。这是一个明文文件,您需要在文本编辑器中打开,然后找到包含值 ro.secure 的行。如果该行称 ro.secure=1 然后需要将其更改为 ro.secure=0 。之后,您可以重新打包ramdisk和boot.img,然后将其闪烁到您的手机上。重启后,每当执行 adb shell 而无需运行 abcdefghijklmn9 su0


第三种选项是在许多情况下,可以使用root权限在设备上重新启动 su1 。一种可能性是从PC终端执行 abcdefghijklmnsu2 ,但这在所有ROM配置上都不适用(必须构建为"UserDebug" 一个)。您也可以尝试 ChainFire的adbd Insecure App 。这不会持续跨重启,因此您需要在任何重新启动手机时再次使用App或 Abcdefghijklmn13


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.

嗯,如果手机扎根,您可以使用"su -c" 命令运行命令。











Well if you phone is rooted you can run commands with the "su -c" command.

Here is an example of a cat command on the build.prop file to get a phones product information.

adb shell "su -c 'cat /system/build.prop |grep "product"'" 

This invokes root permission and runs the command inside the ' '

Notice the 5 end quotes, that is required that you close ALL your end quotes or you will get an error.

For clarification the format is like this.

adb shell "su -c '[your command goes here]'" 

Make sure you enter the command EXACTLY the way that you normally would when running it in shell.

Give it a try, hope this helps.


只需安装 adbd iNecure 。


Simply install adbd Insecure.


您试图以root身份运行?你说你想用root运行adb shell,但你不想使用adb shell?你能澄清吗?



What are you trying to run as root for? You're saying that you want to run ADB shell with root but you don't want to use ADB shell? Can you clarify?

If the application requests for root access, then the SuperUser application on your phone should handle giving it permission or not. The process in which you rooted your phone should have included a SuperUser application.



  adb shell sh /sdcard/myscript.sh   


  su pm setInstallLocation 1   

我刚刚在我的手机上做到了成功,唯一的问题是我没有识别出如何干净地结束adb shell会话。我必须在我的Windows shell中的Ctrl-C返回Windows命令提示符 - 否则adb刚刚坐在 # 提示符上,不接受输入。


As an alternative, you could write your script on the phone and simply have adb execute it, for example:

adb shell sh /sdcard/myscript.sh 

The script can elevate itself without your intervention (assuming SuperUser is set to remember the approval), for example:

su pm setInstallLocation 1 

I just did this on my phone with success, the only problem being that I haven't quite figured out how to cleanly end the adb shell session. I have to Ctrl-C in my Windows shell to return to the Windows command prompt -- otherwise adb just sits at the # prompt and doesn't accept input.




adb shell su -c commands

adb根shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db"插入安全(名称,值)值('device_provisioned','1');"

adb kill-server


i use for repair home button issue failure

adb devices

adb shell su -c commands


adb root shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "INSERT INTO secure (name,value) VALUES ('device_provisioned','1');"

adb kill-server


您还可以在'sh'上设置suid位。 我正在使用busybox,因此说明可能与您的设置不匹配:

  1. adb shell
  2. su
  3. Mount -o Remount,RW / System(或:ADB Remount)
  4. ls -la / system / bin / sh LRWXR-XR-X根壳2012-11-10 15:20 SH - &GT; MKSH
  5. Chmod 4755 / System / Bin / Sh
  6. ls -la / system / bin / mksh
    -rwsr-xr-x根壳157520 2012-11-10 09:54 MKSH (请注意Suid位设置)
  7. ^ d
  8. adb shell



You can also set the suid bit on your 'sh'. I'm using BusyBox so instructions may not match your setup:

  1. adb shell
  2. su
  3. mount -o remount,rw /system (or: adb remount)
  4. ls -la /system/bin/sh lrwxr-xr-x root shell 2012-11-10 15:20 sh -> mksh
  5. chmod 4755 /system/bin/sh
  6. ls -la /system/bin/mksh
    -rwsr-xr-x root shell 157520 2012-11-10 09:54 mksh (notice the suid bit is set)
  7. ^D
  8. adb shell

and you should have the root prompt



49  有没有办法让我以root身份运行adb shell而无需打字“su”?  ( Is there a way for me to run adb shell as root without typing in su ) 
有没有办法让我以root身份运行adb shell而无需键入 su ?我希望能够在没有进入shell的情况下获得root访问权限。 ...

1  没有自定义恢复的任何方法都可以获得root? (解锁引导加载程序)  ( Any way to get root without a custom recovery unlocked bootloader ) 
我有一个带有解锁的引导加载程序的手机(摩托罗拉Moto maxx xt1225)但还没有自定义恢复。 是否有任何方法可以在没有自定义恢复的情况下获取root / flash超级su? 或者以任何方式修改股票恢复以便能够闪现无符号zips? 编辑:设备在4.4.4,它是Droid Turbo的"国际" 版本,刚刚发布...

0  注3 - 应用程序丧生  ( Note 3 apps killed ) 
我有一个rooted注3: 三星-m-n900a(AT&amp; t) Android 4.3 基带N900aucubnb4 我所拥有的问题是,有些东西杀死了应该在后台运行的应用程序。 例如,闹钟。每天,7:00报警设置。由于应用程序已被杀死,警报永远不会熄灭。 "电池保护程序" 模式被禁用。 还有什么,我...

0  我如何在没有USB的情况下将所有文件从手机上完成  ( How can i get all my files off my phone without usb ) 
我有一个"必需的" Android手机植根,拥有终端和超级安装,但不会承认它已插入计算机而不是交流充电站。 lsusb 在主机上找不到它。 在设置下,"USB调试" 为ON。这似乎并没有帮助。 外壳存在并在手机本身上与终端一起使用。 curl 存在。 ssh 和 sshd 不是。我有无线。我如何从手机上获取我的...

1  我如何在我的诺基亚2.1上闪存股票和roidrom - 我曾经弃于PIN码和Google凭据?  ( How do i flash stock android rom on my nokia 2 1 to which ive forotten both p ) 
所以我最近继承了一个通过的相对的诺基亚2.1。我不知道PIN码,也不知道我知道Google凭据04EEDED。 当我进入恢复时,FastBoot模式无法选择,并在另一个文本中与红色文本进行比较。我确实可以让adb识别侧面加载模式中的设备,但是当我尝试闪烁的股票和谐rom时,我下载它给了我错误消息:"签名验证失败(错误...

3  我不能再写入/仿真/ 0而没有root或系统访问  ( I can no longer write to emulated 0 without root or system access ) 
我有一个sprint galaxy笔记3.我扎根了cf自动根,闪过twrp,闪烁的jellybomb,然后恢复到nandroid备份的股票。 我不确定它开始什么时候,但似乎我不能写入sdcard0或仿真/ 0,没有root或系统权限。例如,我可以使用Astro在extsdcard中创建一个新文件夹,只需在SDCar...

19  使用没有root访问的SMB服务器  ( Using smb server without root access ) 
我正在寻找我的HTC Hero(Android 2.1)的方式,所以我可以通过常规Windows文件共享在WiFi网络上分享我的SD卡和电话内存的内容。我想要一个不需要我root手机的人,我愿意为合适的应用支付,所以它不必是免费的。 我在想使用SMB服务器,到目前为止,我发现的只是: sambaandroid ...

7  您如何在扎根的手机上删除预安装的应用程序?  ( How do you remove pre installed apps on a rooted phone ) 
我有一个rooted nexus一个,想要删除一些预安装的应用程序,例如Amazon MP3。 是什么最好的方法? ...

310  我扎根了我的手机。怎么办?我从生根获得了什么?  ( Ive rooted my phone now what what do i gain from rooting ) 
这是那些刚刚扎根手机的人的常见问题。我从rooting获得了什么应用程序,rom,福利等?我现在应该在做什么? ...

3  如何为rooted设备安装其他终端命令的捆绑?  ( How to install bundles of additional terminal commands for rooted devices ) 
我最近扎根了HTC野火S设备并闪过Android 4.1.2 AOKP果冻豆类自定义ROM。一个好处是我现在可以使用终端。 我有点习惯于在台式机上使用终端仿真器,但从中从未在Android设备上做过。我注意到没有找到一些命令,例如: $ tree /system/bin/sh: tree: not found ...

© 2022 it.wenda123.org All Rights Reserved. 问答之家 版权所有