Guide:Using the Terminal for an Android device
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.
Contents[hide] |
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:
- Download and install the Android SDK from http://developer.android.com/sdk/index.html
- The adb executable is included in this package in the tools directory
- Setup your OS to recognize the moment and use it with adb
- Windows
- Make sure to keep adb.exe in the folder it was extracted in (there is a .dll it needs in order to operate properly)
- Make sure the Samsung Moment USB drivers are installed properly.
- Run command prompt.
- Go to the directory where adb has been extracted. (ie: cd program files/etc/etc/android-sdk*/tools/)
- type 'adb shell', hit enter.
- Linux
- Create a file in /etc/udev/rules.d call 50-android.rules
- Edit the file and make it look like:
- SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666"
- You will probably need to restart udev...this is distro dependant usually
- For example on ubuntu: sudo restart udev
- Start the adb server by running adb start-server
- 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...)
- Windows
- 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
- Install any sshd server into your device. I'm using SSHDroid (available on the market), but can use anything else.
- Configure it to allow sshd server without wifi.
- On your computer, use ABD to forward port: in command shell execute:
abd.exe forward tcp:2222 tcp:22
- 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
- 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
Comments
Post a Comment