16

I want to run terminal on my device however the small screen is very inconvenient. I wondering if it is possible to run terminal on real android device from PC?

  • Yes, you can install a ssh server in the device. There is another thing called adbd for doing that, but that's a developers thing. – 43488 Jan 10 '14 at 11:50
  • Could you please explain more, how can I use it? – Jacob Jan 10 '14 at 12:14
14

You can use Android Debug Bridge (ADB) shell to issue basic Linux commands on your phone, just like you would in a terminal emulator app. To install you'll need to do the following:

  1. On the phone go to Settings -> About phone, and tap on "Build number" seven times. This enabled Developer tools.
  2. Go back to the main Settings screen and you should now see Developer options under the "System" section.
  3. Go to Developer options, enable "Android debugging" option, and then tap OK on the verification prompt.
  4. On your PC download the Android SDK Tools from here. You can either download the whole SDK, or just the stuff necessary to connect to your phone, which is on the same page, under "Download for other platforms -> SDK Tools Only" section.
  5. Install the tools you just downloaded.
  6. Download and install the USB drivers for your phone (usually provided by the manufacturer.)
  7. Re-connect your phone to the PC with a USB cable.
  8. Open Command prompt (assuming Windows,) navigate to where you installed the SDK tools (e.g. "C:\android-sdk\platform-tools\") and type in the following: adb devices
  9. If all of the above was done successfully, a prompt should pop up asking you to allow connections from this computer. Accept the pairing request, and the prompt should show your phone's ID. If this doesn't happen - it usually means that the drivers aren't installed correctly.
  10. Back at Command prompt, type in adb shell and press Enter, and you should be connected to the phone's terminal.

This should get you started. ADB commands are listed on Google's site here. The shell provides some basic Linux commands like ls, cp, etc. Be aware that most file and device management commands will require root (i.e. elevated privileges,) which is a separate topic.

5

Alternatively to the ADB variant described by Chahk (which requires at least a minal installation of ADB on your computer), you can install a SSH server app on your device (examples include, but are not restricted to, SSH Server, DigiSSHD, Servers Ultimate). Then you can use the ssh command on Linux/Mac, or a tool like PuTTY on Windows, to connect to your device and run shell commands, as if you were using a terminal app on the device itself.

  • Hi Izzy, I installed PuTTy and SSH Server and defined server name and port on the server. Then I connected the phone to the PC by USB, however connection fails: "host does not exist". What can I do? – Jacob Jan 13 '14 at 12:08
  • Setting up the host (DNS) correctly? Without knowing the command you executed, I can only guess. First try with the device's IP (i.e. enter your Android's IP address in PuTTY) to see whether it works at all. How to make that work with DNS from your computer (so you can use an easy to remember name instead of the IP address), is a question better fitting on either Super User or Server Fault (check their repective help/on-topic pages first where it fits best). – Izzy Jan 13 '14 at 12:31
  • Sorry, I asked you wrong question. The proper one is how I could check IP address of the device? – Jacob Jan 13 '14 at 12:53
  • It should be shown in Settings→About device (on my ICS device, in the Status sub-section as "IP address"). Apart from that, your router should show it on its management console. The hard way would be "pinging" your entire local network to check what responds, or doing a port-scan ;) There are also a bunch of device-info tools available (recommendation: OS Monitor: it offers many useful helpers, apart from showing all IPs of your device {WiFi, mobile, local,...}). – Izzy Jan 13 '14 at 13:01
3

You will need

Your Android phone ( Rooted and with Wi-Fi functionality )
SSHDroid (SSH server)
PuTTY.exe (SSH client)

Setup SSHDroid

    Install “SSHDroid” from android market to your phone this will turn your phone into a SSH server


    For the first time you need to set-up a password to log-in shell. Default password is admin which may you have to change on first time

Setup Putty

    Download PuTTY.exe for SSH Client on your windows PC, it comes in single executable file so you don’t need to install that just double click on that and PuTTY will start.


    There is no need to setting up any thing in PuTTY.

Let’s start

First step is to running Wi-Fi and connect your android phone to target PC, then run SSHDroid server into your mobile phone, but before that make sure under the SSHDroid’s application window click Options -> “Require WiFi” is checked as seen on above pic screen 2. And then click “start” option.
Once SSH server is successfully started it will show IP address of your mobile phone in light sky color like this root@192.168.43.129 as seen on screen 4.
Take the IP “192.168.43.129” and type it to your PuTTY program’s (PC) host field and hit connect. Make sure port number is 22 as seen in second pic.
It will ask for certification click ok and then command line log-in window will appear, type “root” hit enter and then type the password for root user, default is “admin” as i mentioned before. After successful log-in you will be able to use Linux commands like ls, reboot -f, mkdir, find, etc.

if your phone is connected to internet you can also use network commands like ping, wget, telnet etc.

Source : - How to connect android phone to PC using SSH & putty

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.