How can I run Linux commands on an Android device?

前端 未结 6 1895
既然无缘
既然无缘 2020-12-15 10:44

On some Android devices, in the ADB shell, I can only run echo, cd, ls. When I run:

tar -cvf //mnt/sdcard/BackUp1669/a         


        
相关标签:
6条回答
  • 2020-12-15 10:50

    As far as i know, the only way to run shell commands is:

    Process proc = Runtime.getRuntime().exec("your command");
    
    0 讨论(0)
  • 2020-12-15 10:52

    Install busybox, then type the command in the following format:

    busybox [linux command]

    You cannot use all the linux commands without busybox, because Android doesn't have all the binaries that are available in a standard linux operating system.

    FYI, a binary is just a file that contains compiled code. A lot of the default binaries are stored in /system/bin/sh directory. All these commands like 'cp' 'ls' 'get' etc, are actually binaries. You can view them through:

    ls -a /system/bin/sh

    Hope this helps.

    0 讨论(0)
  • 2020-12-15 11:01

    You can probably get this done by using a Terminal Emulator app. As you wrote above, I don't know how well DOS commands will work. But, a Terminal Emulator works without root.

    0 讨论(0)
  • 2020-12-15 11:02

    In reply to Igor Ganapolsky, you would have to have a database set up for locate.

    Probably 'find' would be adequate for your needs.

    exmample:

    find -name *.apk

    0 讨论(0)
  • 2020-12-15 11:04

    If you have the binaries for your system, you can run anything on your system.

    Saying that you have to understand that you have to find the binaries for tar.

    Look here http://forum.xda-developers.com/showthread.php?t=872438

    And possibly other places..

    0 讨论(0)
  • 2020-12-15 11:07

    You can run Linux commands on Android. But there are usually just very few pre-installed. If you want to add more commands you might want to root your device and install busybox on it.

    This is not for productive use within an application but can help you to work with your device.

    0 讨论(0)
提交回复
热议问题