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

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


49
vote

问题

中文

有没有办法让我以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.

     

回答列表

45
 
vote
vote
最佳答案
 

如果我正确地了解你的问题,你会在运行 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

这可能是不言而喻的,但是在这样做时要小心。使用引导分区搞乱可以很容易地破坏手机并强迫您通过Hboot恢复。我强烈建议测试Fastboot以确保您可以使用扩展的FastBoot命令并执行恢复。这基于您的模型变化了一点,但大多数手机都有某种可以运行的桌面软件,以刷新手机。


第三种选项是在许多情况下,可以使用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.

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

以下是build.prop文件上的cat命令的示例以获取手机产品信息。

  su4  

这会调用root权限并在''

内运行命令

注意5个结束引号,这是您关闭所有结束引号的必要条件,或者您将收到错误。

为了澄清,格式就是这样。

  su5  

确保在shell中运行它的方式输入您通常会的方式。

试一试,希望这有帮助。

 

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.

 
 
 
 
2
 
vote

只需安装 adbd iNecure 。

 

Simply install adbd Insecure.

 
 
1
 
vote

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

如果应用程序请求的root访问权限,则手机上的超级用户应用程序应处理或不处理。您扎根于您的手机的过程应包括超级用户应用程序。

 

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.

 
 
       
       
1
 
vote

作为替代方案,您可以在手机上编写脚本,简单地将adb执行它,例如:

  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.

 
 
0
 
vote

我用于修复主页按钮问题失败


adb设备

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

or

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

 
 
-1
 
vote

您还可以在'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

 
 
   
   

相关问题

1  TWRP高级擦拭软砖?  ( Twrp advanced wipe soft bricked ) 
与我的moto g7 plus湖在血统上搞砸了17.1&amp;结束了分区B&amp的TWRP;除了我的inexpertings ovblbers,划分的谱系恢复。很遗憾的是,使用TWRP&amp在A / B上进行了高级擦拭;现在恢复对亚行或触摸无响应。我假设设备是吐司? 所以有没有任何程序来纠正,或者我是否需要流行...

31  通过adb备份和恢复Android设置和应用程序  ( Backup and restore android settings and application through adb ) 
我想询问是否有可能通过adb备份和恢复所有Android设置和应用程序。 我试过: adb backup -all adb: unable to connect for backup 它不起作用,而所有其他命令都在工作。 是可以使用这个 bmgr ...

4  adb pull - 将整个文件夹复制到计算机  ( Adb pull copy whole folder to computer ) 
如何将文件夹从android设备复制到我的计算机的某个文件夹? 如果我使用这个命令: adb pull efs 它将EFS文件夹的内容复制到我的计算机根目录。我想用它的内容复制整个文件夹到我的计算机的某个目的地。 我试过下面的例如,没有成功 adb pull efs C:Users (我的and...

1  将adb权限更改为rw? [复制]  ( Change adb permissions to rw ) 
这个问题已经在这里有答案: 如何挂载/系统可重写或只读? (RW / RO) (2个答案) ...

7  如何使用adb更改“首选网络模式”而无需重新启动?  ( How to change preferred network mode using adb without reboot ) 
我正在尝试将手机的(cm 12,股票4.2,rooted)首选的网络模式从"gsm / wcdma" (0)更改为"WCDMA仅" (2),反之亦然(可以有其他模式也是)仅使用命令行。基于这个答案我可以使用命令将相关变化与 Settings.db 进行相关变化: adb shell su settings...

43  有没有办法查看内部并修改adb备份创建的文件?  ( Is there a way to look inside and modify an adb backup created file ) 
我创建了我的Galaxy Nexus的备份,其中 adb backup 。生成的文件名为backup.db,它是某种方式加密。 我想恢复备份,但它在恢复 com.android.providers.contacts 时停止。我使用 adb logcat ,了解正在发生的事情,并发现 com.android.acore...

2  arshmallow上的adb备份 - 它是不同的吗?  ( Adb backup on marshmallow is it different ) 
设备和设置: moto x播放(股票6.0.1), unrooted , USB调试在开发人员选项中启用并使用 adb devices 验证。其他USB / Developer选项,如在 下面的图片中 使能桌面备份密码此处推荐 adb备份命令在非生根设备上创建一个空备份文件? 设备未加密 在设备...

6  如何使用Yaffs2访问.img文件?  ( How do i access img files with yaffs2 ) 
我已经尝试在Ubuntu中安装它们,没有运气, mount 无法识别Yaffs2文件系统。我尝试了 yaffs2utils 和 ./unyaffs2 但它实际上并没有解压缩IMG文件,我在Google代码页 here 。 IMG文件是由CWM恢复为备份创建的,我正在尝试挖掘文件系统以查找旧联系人,如果我可以获得.d...

7  如何通过adb shell提取.zip  ( How to extract zip through adb shell ) 
标题所说的准确。我的SDCard上有一个1.5 GB的zip文件,我想通过adb提取(未拔去电脑并推回)。有没有一个简单的命令来解压缩文件? 谢谢! ...

5  通过sshdroid(或adb shell)运行tasker任务  ( Running a tasker task via sshdroid or adb shell ) 
我正在尝试通过sshdroid从adb shell手动运行任务任务。我是 在Putty中运行以下内容(Windows SSH客户端): am broadcast -a net.dinglisch.android.tasker.action_task -es task_name 沉默 我得到: 广播:意图{ac...

0  Nexus 10未在Debian Wheezy / Mac OS / Windows 8上识别adb  ( Nexus 10 not recognized on debian wheezy mac os windows 8 with adb ) 
我正在尝试将我的平板电脑Nexus 10 + Android 4.4 + Cyanogen-Mod 11连接到我的桌面电脑,我已经使用亚行安装了Debian Wheezy。它在前段时间工作,现在它既不再使用Debian Linux也不是Windows 8或Mac OS。在这里检查: root@localhost:...

14  'adb push'和'adb安装'之间有什么区别?  ( Whats the difference between adb push and adb install ) 
将 adb push 只将文件复制到目标位置,而 adb install 将文件复制到目标位置和也设置了正确的权限你? ...

0  通过WiFi连接时的adb问题  ( Adb issue while connecting through wifi ) 
我正在使用此命令从计算机运行adb端口转发到mobile: adb forward tcp:6401 tcp:50000 在我通过同一台计算机访问它时,它完全正常(访问127.0.0.1),但是一旦我尝试通过当地WiFi(本地IP 192.168.1.134)即可达到它,我会得到"连接拒绝" 。我做错了什么...

1  如何通过adb备份和恢复APN设置?  ( How to backup and restore apn setting via adb ) 
如何通过adb备份和恢复APN设置? 我在没有root的Android 6.0上。 ...

50  adb backup创建0字节文件;即使我从未设置为一个,也会提示当前备份密码; “无法设置密码”桌面备份密码  ( Adb backup creates 0 byte file prompts for current backup password even though ) 
问题: 每次运行adb备份时,我会在主屏幕底部附近的消息说 Backup starting... ,后跟一条消息,然后是一条消息,然后是一条消息 Backup finished 几秒钟后来尽管我正在使用17 GB的设备内存,并且使用0个字节的大小创建生成的备份文件。我没有收到错误消息,没有反馈,无论是什么都是错误的...




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


Licensed under cc by-sa 3.0 with attribution required.