Please remember to add a category to the bottom of each page that you create.
See categories help for further details, but most will probably be [[Category:HTC ModelName]].

Guide:Using the Terminal

From XDA-Developers
Jump to: navigation, search

In this wiki, a lot of actions have to be preformed in the console. There are GUI alternatives for the commands, but often it is harder to describe a GUI sequence (a lot of screen shots). In some cases, no applications has been written that can do the same. Every Android device has a console. There are a couple of ways to talk to the console, on the phone via an terminal emulator, via adb shell over an usb cable or over wifi using sshd.

Different methods

Terminal Emulator

In the market, find Terminal Emulator and install. Now you can access the Android shell using on the phone itself. Start the application and type

$ su
#

Assuming you have rooted your phone, you now have full control!

ADB Shell (link)

To install and use the ADB tool:

  1. Download and install the Android SDK from http://developer.android.com/sdk/index.html
    1. The adb executable is included in this package in the tools directory
  2. Setup your OS to recognize the moment and use it with adb
    1. Windows
      1. Make sure to keep adb.exe in the folder it was extracted in (there is a .dll it needs in order to operate properly)
      2. Make sure the Samsung Moment USB drivers are installed properly.
      3. Run command prompt.
      4. Go to the directory where adb has been extracted. (ie: cd program files/etc/etc/android-sdk*/tools/)
      5. type 'adb shell', hit enter.
    2. Linux
      1. Create a file in /etc/udev/rules.d call 50-android.rules
      2. Edit the file and make it look like:
        SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666"
      3. You will probably need to restart udev...this is distro dependant usually
        For example on ubuntu: sudo restart udev
      4. Start the adb server by running adb start-server
        1. In some cases you may have to start the server as root by doing sudo adb start-server. This may be remidied by modifying the above file to something like SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", OWNER="username" where username is your user name (although this did not help in my situation...)
  3. Run 'adb devices' and check to see if your device is listed

How to use ADB, along with the command listing - http://developer.android.com/guide/developing/tools/adb.html

SSHD

  1. Install any sshd server into your device. I'm using SSHDroid (available on the market), but can use anything else.
  2. Configure it to allow sshd server without wifi.
  3. On your computer, use ABD to forward port: in command shell execute:
abd.exe forward tcp:2222 tcp:22
  1. Now you can connect to your device from your computer with your favorite ssh client using 'localhost:2222'. I'm using putty.


Avantage:
With putty, you have a very good console:

  • Arrow keys and history work fine.
  • You can copy/paste with mouse
  • Completion with <tab>-<tab> works fine.

Useful commands

Root Access

$ su -

Change directory

From current directory to '/system':

# cd /system

From current directory (assume '/system') to one down with the name 'app' (now in '/system/app'):

# cd app

From current directory, one up (back to '/system'):

# cd ..

List all files

List all files in current directory:

# ls

List all files in '/system/app':

# ls /system/app

List all files with the word 'Time' in it (case sensitive):

# ls *Time*

Mount

Get mount info:

# mount

Mount '/system' as read-write:

# mount -o rw,remount -t yaffs2 /dev/block/mtdblock0 /system

Mount '/system' as read-only:

# mount -o ro,remount -t yaffs2 /dev/block/mtdblock0 /system

Move, Copy and Remove

Move file from a to b

# busybox mv a b

Copy file from a to b

# busybox cp a b

Remove file a

# busybox rm a

Reboot

# reboot

Links

Android - under the hood - Terminal Emulator Commands