How to use su command over adb shell?

前端 未结 6 1928
悲&欢浪女
悲&欢浪女 2020-12-14 17:44

I need to make a script that executes a lots of thing on Android device, my device is rooted, when I enter on the shell, I can give the command su, and it works but I need p

6条回答
  •  庸人自扰
    2020-12-14 18:32

    Well, if your 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 phone's 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.

提交回复
热议问题