If someone finds a mistake, please notify me and I will correct it. -> voku1987

PLEASE NOTE THAT I AM NOT RESPONSIBLE FOR YOU MESSING UP YOUR PHONE!

Introduction

The Linux terminal is a command-line interface that you can use for all types of operation on the Android OS. A lot of users are afraid to use it because it 's not a GUI, and to be honest, if you don't know the basics it's pretty hard to learn by yourself.

How to Install

Phone Setup

In order to use ADB, you have to enable USB Debugging option in  phone settings (Settings->Applications->Development)

How to Use

Notes:

* Don’t use it if you don’t know what you do!!!!

* Commands and folders are CASE-SENSITIVE (lall != laLl != Lall …)

* Commands can use easy-regular-expressions (e.g. rm *.lall -> deleted everything that ends with “.lall” in this directory)

* If a command completed successfully, it will say nothing and start a new line

Default adb commands

1.) Check connected phone

Syntax:

adb devices

2. Login to Android shell

Syntax:

adb shell

Note:

If you get ‘#’ after typing adb shell, you are already get root access on the phone, no need to type su. Otherwise if you get “$” , type “su” (su = substitute user) to get root access (only for rooted device).

3. show the Android-Logfile

Syntax:

adb logcat

V —> Verbose (lowest priority)

D —> Debug

I —> Info

W —> Warning

E —> Error

F —> Fatal

S —> Silent (highest priority, on which nothing is ever printed)

# e.g. Error messages

Syntax:

adb logcat *:E

radio —> View the buffer that contains radio/telephony related messages.

events —> View the buffer containing events-related messages.

main —> View the main log buffer (default)

# e.g. all event messages

Syntax:

adb logcat -b events

Some usefull shell commands

Note: (“ls” == “dir” in Windows-cmd)

If you need more information about files/directories then add the parameter “-la”!

Example:

ls /system/libcp

Notes:

Absolute paths work everywhere, from every folder. They always start with "/", which is the root (the start). On android, then you have some subfolders like "system", "data" and "sdcard" (which is the sdcard).  An example of an absolute path would be /sdcard/videos (the folder videos on your sdcard)

Relative paths are relative to your position as the name would suggest.

If you currently are in the /sdcard folder, you can just switch to the videos directory by using the command: cd videos

Note:

There are several commands for file operations. They will be explained in the next section. Please note that removing important system files may harm your system. If you're not 100% sure, don't try it before you are!

To copy or delete files in Android root directories you have to change the directory access mode to “read and write (rw)” [“read only (ro)”] using command: remount rw

Example_1: … this will copy bootanimation.zip from the sdcard to the folder where it is loaded at boot. It will overwrite the current bootanimation.zip in that folder.

remount rw /system

cp /sdcard/bootanimation.zip /system/media/

remount ro /system

Example_2: will replace the default android font with segoeui, and rename segoeui.ttf to DroidSans.ttf so Android recognises it.

remount rw /system

cp /sdcard/fonts/segoeui.ttf /system/fonts/DroidSans.ttf

remount ro /system

PS: you can also use e.g. “ES File Exporer” for copy & past files

Example: show a file named lall.txt in /system/data/

cat /system/data/lall.txt

“or”

cd /system/data/

cat lall.txt

Example:

mv /system/lib/libsec-ril.so /sdcard/backupchmod

Example:

chmod 0644 /system/lib/libsec-ril.sorm

Notes:

First you need to know how permissions work in Linux.

It works with 3-numbers: “xyz”

x - is what the owner can do

y - is the permission for the public user

z - is what other users can do (public = dangerous)

x,y and z can have different values:

7        full (read, write, execute)

6        read and write

5        read and execute

4        read only

3        write and execute

2        write only

1        execute only

0        none

Example:

rm /system/lib/libsec-ril.so4. Install application

Note:

- press “P” and the output will be ordered by CPU-usage

- press “M” and the output will be ordered by Memory-usage

Example: show only the system-mount

mount | grep system

Example_1: copy the output from Android-Debug to your SD-Card

logcat -f /sdcard/logcat.txt

Example_2: copy the output from Kernel-Debug to your SD-Card

dmesg > /sdcard/dmesg.txt

Example_3: change CPU-Governor to e.g. conservative  

echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

Some usefull adb commands

Syntax:

adb reboot

Syntax:

adb reboot recovery

Syntax:

adb install appname.apk

Example:

D:\android-sdk-windows\tools\adb install D:\AnReboot.apk

Syntax:

adb pull source [destination]

Example:

D:\android-sdk-windows\tools\adb pull /sdcard/arm11-dvm.zip

D:\android-sdk-windows\tools\adb pull /sdcard/arm11-dvm.zip D:\

Syntax:

adb push source destination

Example:

D:\android-sdk-windows\tools\adb push D:\AnReboot.apk /sdcard

Syntax:

adb forward tcp:[source-port] tcp:[destination-port]

Example:

adb forward tcp:5901 tcp:5901

sources: 

- http://s2tip.blogspot.de/2012/02/how-to-use-android-adb-command-line.html

- http://forum.samdroid.net/f38/howto-android-debug-bridge-adb-4378/

PS: there are also good videos on youtube about “android adb” if you need some live examples ;)