adb shell and terminal emulator - Android Q&A, Help & Troubleshooting

i gotta question. is adb shell and terminal emulator the same thing? and am i right getting into adb shell with the CMD from windows when having my phone via usb connected in debugging mode? and can someone tell me where i can get a list of commands?
thx
X10mini miniCM7 2.0 using XDA Premium App

freebordjunky said:
i gotta question. is adb shell and terminal emulator the same thing? and am i right getting into adb shell with the CMD from windows when having my phone via usb connected in debugging mode? and can someone tell me where i can get a list of commands?
thx
X10mini miniCM7 2.0 using XDA Premium App
Click to expand...
Click to collapse
adb shell and Terminal Emulator are not the same thing. One is an shell environment (adb shell) and the other is a tool to access that environment (Terminal Emulator).
adb shell is native to the phone and allows for Linux shell access. Terminal emulator will allow you to run adb shell ON the phone directly to access that shell environment.
Secondly, yes you are correct, in that you can use the Command Prompt (CMD) to access adb shell. Also, your phone must be in debugging mode as you stated.
To get a list of commands -- you type: adb, while in the androidsdk\tools folder and it'll display the default set of commands available to you.
Though, the most common commands you'll run are as follows:
adb shell -- Gives you shell access, best used with root access
adb remount -- Mounts the phone for r/w (read-write) access; this
needs to be done if you plan to run the next two commands, but only once.
adb push -- Push's/Move's a file to the specified dir, usually system/app
adb pull -- Copies a file from a specified dir, usually system/app
adb shell reboot -- Reboots your phone from the command line
Hope that helps.

thank you very much
X10mini miniCM7 2.0 using XDA Premium App

Sure, no problem.

pseudoremora said:
Sure, no problem.
Click to expand...
Click to collapse
Hi there, Im new to TE and ADB as well.
1) From what it looks like why would you ever use ADB if you didnt need to exchange files with the computer?
TE seems a lot easier to use without having to install the sdk, different exes etc.
2) I've also stumbled upon the ADBD insecure by chainfire, from what I've gathered, this app gives you root access to stock kernels that otherwise wouldn't have given you that. and saves you from typing long command lines.
But what lines is it saving you from typing? Just "su"?

Adb pull or push DOES NOT work with Terminal Emulator as they are not found as commands. What to do to use them with unrooted phone?

pseudoremora said:
adb shell and Terminal Emulator are not the same thing. One is an shell environment (adb shell) and the other is a tool to access that environment (Terminal Emulator).
adb shell is native to the phone and allows for Linux shell access. Terminal emulator will allow you to run adb shell ON the phone directly to access that shell environment.
Secondly, yes you are correct, in that you can use the Command Prompt (CMD) to access adb shell. Also, your phone must be in debugging mode as you stated.
To get a list of commands -- you type: adb, while in the androidsdk\tools folder and it'll display the default set of commands available to you.
Though, the most common commands you'll run are as follows:
adb shell -- Gives you shell access, best used with root access
adb remount -- Mounts the phone for r/w (read-write) access; this
needs to be done if you plan to run the next two commands, but only once.
adb push -- Push's/Move's a file to the specified dir, usually system/app
adb pull -- Copies a file from a specified dir, usually system/app
adb shell reboot -- Reboots your phone from the command line
Hope that helps.
Click to expand...
Click to collapse
I tried the following from powershell, on windows:
Code:
.\adb.exe shell cmd overlay enable com.android.internal.systemui.navbar.gestural
and it worked.
I tried the same from the terminal emulator, and it said
cmd: service not found: overlay
Click to expand...
Click to collapse
Why is it that it works one way, and not the other way? Aren't they interacting with the same shell enviromnent? Is there a permission difference?

Related

[REQ] /system/bin/sh clockwork recovery

I just did a major mistake by copying sh from Windows to /system/bin/sh. Not haivng the execute bit has stopped me from using adb shell.
Could someone provide a clockworkmod recovery file that restores sh & it's permissions? I would greatly appreciate it. Thanks!
Why not just run the fix permissions script from the advanced menu in clockworkmod?
Sent from my SCH-I500 using XDA App
well, would be easier from a linux box:
chmod 755 sh
adb push sh /system/bin/sh
adb reboot
i_am_enderst said:
well, would be easier from a linux box:
chmod 755 sh
adb push sh /system/bin/sh
adb reboot
Click to expand...
Click to collapse
Thanks. I fixed it through recovery mode shell via adb.
I'm getting the following garbage when I do ls within adb shell. Is there any way to fix this?
Code:
# ls
ls
←[1;34mcache←[0m ←[1;32minit.rc←[0m ←[1;34msbin←[0m
←[1;34mconfig←[0m ←[1;32minit.smdkc110.rc←[0m ←[1;34msdcard←[0m
←[1;34mdata←[0m ←[1;32minit.smdkc110.sh←[0m ←[1;34msqlite_stmt_journals←[0m
←[1;34mdbdata←[0m ←[1;34mlib←[0m ←[1;34msys←[0m
←[1;32mdefault.prop←[0m ←[1;32mlpm.rc←[0m ←[1;34msystem←[0m
←[1;34mdev←[0m ←[1;34mmnt←[0m ←[1;32msystem.prop←[0m
←[1;34mefs←[0m ←[1;34mpreinstall←[0m ←[1;34mtmp←[0m
←[1;36metc←[0m ←[1;34mproc←[0m ←[1;34muserdata←[0m
←[1;32mfota.rc←[0m ←[1;32mrecovery.rc←[0m
←[1;36minit←[0m ←[1;34mres←[0m
Those are bash color escape codes but I don't know why adb is outputting them since I'm new to Android.
It's a windows command prompt thing..
Easiest solution, do this from your adb shell (you'll need to do it each time)
export LS_COLORS=none
alternatively you can installed cygwin and spend a little time setting it up so that the ANSI colors are displayed when using adb shell.
I assume the colors show up fine under linux, which is why this got included in some kernels/rom packages without anyone addressing it.
Thanks for the info. It shows up correctly through a cygwin terminal. I'll just use that for now on.

Remount

What do we need to be able to do adb remount?
Make sure you are in the right directory as your tools folder. Adb remount. Usb debugging needs to be enabled.
Sent from my Motorola Photon 4g
coldblooded79 said:
Make sure you are in the right directory as your tools folder. Adb remount. Usb debugging needs to be enabled.
Sent from my Motorola Photon 4g
Click to expand...
Click to collapse
Code:
[email protected]:/$ sudo su
[email protected]:/# cd /home/max/sdk/tools
[email protected]:/home/max/sdk/tools# ./adb shell
$ su
# exit
$ exit
[email protected]:/home/max/sdk/tools# ./adb remount
remount failed: Operation not permitted
[email protected]:/home/max/sdk/tools#
I was trying to do something similar (adb root). maybe the scripting portion of the adb commands are meant to be embedded in other scripts using adb daemon?
in the kernel needs to have it set to ro.secure to enable abd access with root by default.
speaking of how does moto do its kernels? samsung uses zimages, htc and some samsungs use boot.img
After rooting via the Droid 3 method, you can issue an "adb remount" with no problems...
Beach_Head said:
After rooting via the Droid 3 method, you can issue an "adb remount" with no problems...
Click to expand...
Click to collapse
+1
Did sections 1 & 2 of this and can now use remount command.

[Q] Read partitions without rooting

I'm trying to find an universal way to read userdata partition(dump partition) without rooting the device.
Assumption :
the device can be boot in fastboot mode
Possible ways :
1. Using fastboot
I've looked into fastboot.c, it taking usb as a usb_handle pointer. I'm trying to move from that point. Fastboot is mostly to write or erase, but I assumed if writing and erasing are possible, reading should be possible as well.
2. Using nvflash, tftp...
It won't be the solution, since it's chip dependent but using chip vendor's download tool to dump partitions.
Go for it!
How does using adb dumping from /dev/mmcblk0p1 sounds?
can I unmount mmcblk0p1, and mount back to readable position?
what device? more info please.
dd if=dev/mmcblk0p? of=data.img bs= 8096 is usually the easiest. (<--just an example)
also this may be helpful:
http://forum.xda-developers.com/showthread.php?t=1247908
chrisrotolo said:
what device? more info please.
dd if=dev/mmcblk0p? of=data.img bs= 8096 is usually the easiest. (<--just an example)
also this may be helpful:
http://forum.xda-developers.com/showthread.php?t=1247908
Click to expand...
Click to collapse
Thanks for the link. using dd command is the exact way I used to dump mmc block as root. Or can it be run under not-rooted phones?
Rooting depends on the kernel version of devices, so when I have to dump various phones, it's very cumbersome to root different kinds of devices and dump.
So I'm finding a way to walk around the problem by using fastboot or if possible adb.
I think fastboot is my best bet so far.
How about adb?
adb shell
df -h
kkiqq1208 said:
How about adb?
adb shell
df -h
Click to expand...
Click to collapse
df -h will only show usage of storage medias. Is there anyway I can read off the actual data?
As already mentioned, dd, but via ADB. I believe that it functions at a low enough level that you should be able to dump mmcblk0 without having to be rooted. If dd can't be directly accessed via adb, you could extract a busybox install from a rooted phone and set it up in your adb directory and then run it from there with busybox (in theory).
Волк said:
As already mentioned, dd, but via ADB. I believe that it functions at a low enough level that you should be able to dump mmcblk0 without having to be rooted. If dd can't be directly accessed via adb, you could extract a busybox install from a rooted phone and set it up in your adb directory and then run it from there with busybox (in theory).
Click to expand...
Click to collapse
Question.
Feels like i'm on the different page from you. If i run dd for /dev/mmcblk0 it does give me an error message saying "Access Denied" of couse mmcblk0 is owned by root. And busybox too(I haven;t tried this), it's just a set of linux commnads, I'm not sure how it can access a file(in this case, a device) which does not have its ownership.
Please correct me if I'm wrong.
Hi All,
There is a way to dump any partition to SD card partition on unrooted device vi ADB.
Paste this couple of lines into the terminal :
adb kill-server
adb wait-for-device
adb shell "echo ro.kernel.qemu=1 > /data/local.prop"
adb reboot
adb wait-for-device
adb shell "mount -wo remount rootfs /"
adb shell "rm /data/local.prop"
adb shell dd if=/dev/block/mmcblk0p1 of=/sdcard/mmcp1.dump
The phone may reboot many time after that, so make sure the file /data/local.prop is deleted after this operation. or execute this :
adb reboot
adb wait-for-device
adb shell "rm /data/local.prop"
adb reboot
hope that helps
__________________
HTC One X (SFR)
Wissam said:
Hi All,
There is a way to dump any partition to SD card partition on unrooted device vi ADB.
Paste this couple of lines into the terminal :
adb kill-server
adb wait-for-device
adb shell "echo ro.kernel.qemu=1 > /data/local.prop"
adb reboot
adb wait-for-device
adb shell "mount -wo remount rootfs /"
adb shell "rm /data/local.prop"
adb shell dd if=/dev/block/mmcblk0p1 of=/sdcard/mmcp1.dump
The phone may reboot many time after that, so make sure the file /data/local.prop is deleted after this operation. or execute this :
adb reboot
adb wait-for-device
adb shell "rm /data/local.prop"
adb reboot
hope that helps
__________________
HTC One X (SFR)
Click to expand...
Click to collapse
Has anyone verified if this works for reading partitions on a non-rooted phone?
This doesn't work on an unrooted, locked device.
Code:
C:\Windows\System32>adb shell "echo ro.kernel.qemu=1 > /data/local.prop"
/system/bin/sh: can't create /data/local.prop: Permission denied
This did not work for my phone.
I got "permission denied" right after
adb shell "echo ro.kernel.qemu=1 > /data/local.prop"
Most of the above will only work on a rooted device with superuser.
The loop holes for shadow copies are mostly fixed since 6.0.
Partitions that can be accessed without root can be dumped with DD through ADB if ADB itself is supported and not internally limited to prevent just this.
Try
Code:
adb reboot recovery
adb root
adb shell
In my device, I can able to read those /data /dev without bootloader unlocking or root.
HemanthJabalpuri said:
Try
Code:
adb reboot recovery
adb root
adb shell
In my device, I can able to read those /data /dev without bootloader unlocking or root.
Click to expand...
Click to collapse
So, ... You are lucky. If I try these commands, I am getting "error: closed". And believe it or not, I have my bootloader UNlocked. It's a doomed chinese tablet, Allwinner 100 SOC.
observingman said:
So, ... You are lucky. If I try these commands, I am getting "error: closed". And believe it or not, I have my bootloader UNlocked. It's a doomed chinese tablet, Allwinner 100 SOC.
Click to expand...
Click to collapse
I found that it is common for many Realme devices to able to use `adb root` in recovery mode.
I have a Realme C12 which has Mediatek Helio G35 MT6765G SoC. So we can also able to `readback` partitions by using SP Flash Tool with the help of MTK-bypass.

cygwin does not show shell from phone after running adb shell

I have installed cygwin64 and when I run adb shell, I get no shell prompt, but I can still run commands.
However, if I run adb shell from cmd.exe, it does show the phone's shell after running adb shell. Here is the phone's shell that is shown to me in cmd.exe:
bullhead:/ $
I've run into this same issue. Have you discovered a solution?
For now, I'm using Windows PowerShell (instead of cmd.exe) to access adb shell.

Need help writing script

Greetings,
I have these commands I run from cmd :
Code:
adb shell settings put secure qs_tile_row 2
adb shell settings put secure qs_tile_column 5
adb shell settings put secure sysui_qqs_count 5
The thing is, that these do not survive a reboot, so I wanted to create a script that would run the shell commands on boot.
I created a file in init.d but I can't get a hold of the syntax to put these exact 3 commands.
Any help is appreciated.

Categories

Resources