How do I run "adb shell" commands in a terminal emulator locally on an Android device?

how to run wikihow
how to run for beginners
running technique for beginners
how to run faster
running form
learn to run
proper running form feet
efficient running technique

From a shell on my PC, I can run adb shell cmd package list packages, and get a list of all installed packages. I would like to run this and similar commands locally on my Android phone (Nexus 6P) in a terminal emulator (currently using Termux).

If I open the same shell with /system/bin/sh, and then try to run /system/bin/cmd package list packages, nothing happens (no errors, just outputs nothing and reloads the prompt).

If I run /system/bin/cmd -l the list of options appears as expected. $PATH and $LD_LIBRARY_PATH are the same in both environments. One major difference is that echo $USER returns "shell" from adb shell, but returns my local username from /system/bin/sh launched from Termux.

Is there any way to replicate the behavior of commands run from adb shell in a terminal emulator locally on Android?

Edit: My device is rooted, and I am OK with root only solutions.

Proper Running Form, How to Run. Running is a great way to stay in shape and have fun -- in fact, it's practically Duration: 1:01 Posted: Oct 2, 2019 To Recap: strength train, reduce your calorie consumption, and begin a low impact activity – build up your foundation to prep your body for running. The less weight your body has to carry around, the less work your legs and joints have to do, the less likely you’ll be to damage your joints and/or injure yourself.

The problem is Termux. By design, Termux runs only (or is mostly?) the Linux command line programs that you install from within Termux using apt or the newer "native" package management interface, e.g. apt install bsdtar. What you need to run the adb shell commands is a terminal emulator that can truly access the underlying Android file system, not just the Termux that is practically a chroot save for the fact that it's aware it's not running commands from the filesystem root /.

As a simple test, run the following command:

    which ls

It should return something like /system/bin/ls. But if it returns something like /data/data/com.termux/files/usr/bin/applets/ls then you have to change your terminal emulator to something else. I suspect that Termux was designed to take into account the more restrictive shell execution policies that Google put into place after KitKat or the Android 4.X.

The Android distribution I'm using, LineageOS 14.1, comes with a built-in shell emulator that allows me to run commands found in /system/bin/ls.

6 Ways to Run, Try the following five steps to start your running practice: Get comfortable walking for 20 minutes. That's it. Bump it up to 30 minutes. After 20 minutes is no problem, take it to the next level for a 30-minute walk. Start run/walking. Now, run for longer. Before you know it, you will be a runner. Just click the Search or Cortana icon in the Windows 10 taskbar and type “Run.” You’ll see the Run command appear at the top of the list. Once you’ve found the Run command icon via one of the two methods above, right-click on it and select Pin to Start. You’ll see a new tile appear on your Start Menu labeled “Run.”

EDIT I originally answered this without the termux tag in mind. This worked for me while trying to execute shell commands on a vanilla emulator and saw this question while researching, so I tried to answer it differently.

You almost had it there in your question. You only need to execute sh:

int result = -1;
try {
    final Process shell = Runtime.getRuntime().exec("sh");
    final DataOutputStream commands = new DataOutputStream(shell.getOutputStream());
    commands.writeBytes("write a series");
    commands.writeBytes("of commands here");
    commands.writeBytes("exit\n");
    commands.flush();
    result = shell.waitFor();
  }
} catch (Exception e) {
  e.printStackTrace();
}

If result == 0 the commands were succesful, else otherwise

How to Run Properly (4 Steps for Beginners to Start Running), Running doesn't come naturally to all of us, however, it's something that we are never Duration: 9:35 Posted: Mar 14, 2020 You Just Move At Full Speed There Isnt Any Special Buttons For "Running" Yeayaman - 5 years ago 0 0 On PC, there are different buttons to press/hold to run, but, on console, how much you push the

How To Run Properly, This video is about how to run properly for beginners, using these 5 "must-follow" steps Duration: 17:56 Posted: Nov 18, 2016 To run the application, the dotnet run command resolves the dependencies of the application that are outside of the shared runtime from the NuGet cache. Because it uses cached dependencies, it's not recommended to use dotnet run to run applications in production.

How to Run Properly for Beginners, Evolutionary biology professor Daniel Lieberman, whose studies are the scientific backbone for Duration: 2:16 Posted: Aug 6, 2012 Map a run, walk, or bicycle ride. Plan routes, calculate distances, view elevation profiles, share routes, export as gpx, or embed in a website.

How To Run: DOs & DON'Ts, A fixed race date will help you stay focused, and keep you on a regular running schedule. A beginner can run any race — you just need to allow enough time to� Double-click the “cmd.exe” file or right-click the file and choose “Run as administrator.” You can also create a shortcut to this file and store the shortcut anywhere you like. Open Command Prompt from the Run Box Press Windows+R to open “Run” box. Type “cmd” and then click “OK” to open a regular Command Prompt.

How to Start Running - Well Guides, Regular running for beginners means getting out at least twice a week. Your running will improve as your body adapts to the consistent training stimulus. It's better to run twice a week, every week, than to run 6 times one week and then do no running for the next 3 weeks. Do you meet or exceed the game’s system requirements? – How it works. This site provides a One-Click solution that looks at your computer's hardware and system software to determine whether or not your current system can run a product.

Comments
  • you may refer to github.com/termux/termux-app/issues/77
  • Thanks for link. However, I think that link is actually trying to do the opposite of what I want: emulate the behavior of termux from adb. I actually want to emulate the behavior of commands run from adb shell in a shell running locally on the device. My confusion is that I am running the same binary using the same shell binary on the same device and getting a different output (technically no output when run locally).
  • Thanks for the detailed response. I didn't know about some of these settings/commands. I am using Magisk for root, but root seems to be working correctly. Unfortunately, this command still gives me the same result, at least for the "cmd" command. It just returns nothing. I tried on a Nexus 5x running Nougat to make sure it wasn't the device, and same result: works in adb shell, null in Termux with your command. Must be a change introduced in Nougat?
  • Worked for me on Pie.
  • It tells me no device it attached (nor does it find any devices). Would you know why?
  • @DADi590 I assume your device does not have USB debugging enabled
  • @Chrisko It does though. That's why I didn't understand why it didn't work.
  • @DADi590 if adb devices doesn't give you anything, there's a bunch of answers you can go through: stackoverflow.com/questions/15721778/adb-no-devices-found
  • Ah but it works on PC. Just not on the emulator. I'll search a bit deeper about it then. Thanks