If someone finds a mistake, please notify me by PM and I will correct it.
PLEASE NOTE THAT I AM NOT RESPONSIBLE FOR YOU MESSING UP YOUR PHONE!
Introduction
The Linux terminal is a commandline interface that you can use for all types of operation on the Android OS. Alot 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. - http://developer.android.com/guide/d...tools/adb.html
Why is this useful? So you do not have to rely on apps like Root Explorer/Astro File Manager/Estrongs File Explorer/etc... for some operations.
In this tutorial I will get you started with the basics of the terminal in a way everyone can understand.
1. Preparation
First, we must look at the Android-SDK -> download and install or you can also use the "Terminal Emulator"-App to access to the Android-Shell but you can clearly work better with a keyboard (PC) on the shell. 
1.1) Drivers
If you have never connected your phone to your PC, you may need to also install the drivers.
“Windows XP” -> “SAMSUNG New PC Studio”
“Windows 7” -> “SAMSUNG Kies“
... here you can also find the drivers for Spica -> Samsung USB Drivers
1.2) Installation
first extract "android-sdk*.zip" and we copy "android-sdk-windows" to C: and run the included "SDK Manager.exe".
1.3) activate USB Debug
Enable USB debug on the phone ...
Settings – Application – Development: „USB-Debugging“
... and then connect your Android to your PC via USB.
2.) ADB-Commands
Now start the Windows command line ...
... and can now run the following commands.
# change in folgndes Directory
Code:
cd C:\android-sdk-windows\platform-tools
# display ADB-Help
# shows the connected Android devices
# Android will be re-launched
# Android will be started in recovery mode
Code:
adb reboot recovery
# start the Android-shell
# show the Android-Logfile
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
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
Code:
adb logcat -b events
# installed an app from your PC
# Upload a file from your computer (local file) to mobile
# Download a file from phone to your PC
e.g.: screenshots with a 24BPP kernel (download from here)
Code:
adb pull /dev/graphics/fb0 fb0
ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -s 320x480 -i fb0 -f image2 -vcodec png image.png
# a TCP port of Android directly connect to a TCP port of our operating system
Code:
adb forward tcp:5901 tcp:5901
In the CyanogenMod - wiki, there are other useful commands:ADB - CyanogenMod Wiki
--- The following commands are executed in the "adb shell" ---
In this case, most of the following commands can be used in other Linux systems ...
# displays the log file
# shows on the kernel debug info
# shows the system apps (ls = dir in Windows)
# shows the installed apps
# displays data on your SD card
# displays the contents of a file or copy it :-)
Code:
cat lall.txt
cat lall.txt > lall_copy.txt
# shows who you are ;-)
# displays the running processes
# shows the system utilization
# shows all mounted partitions
# grep filters e.g. Expenditure
Code:
mount | grep system
# root privileges (su = substitute user)
# partitions can now be described
# e.g. the partition /system may now be written (read & write)
# the partition /system may no longer be written (read only)
# e.g. deletes a system app (rm = del in Windows)
# deletes an installed app
3.) Basic operations
2.1. File Paths
2.1.1 Absolute paths
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)
2.1.2 Relative paths
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:
2.2 File operations
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!
2.2.1 Copy a file/folder
Type:
Code:
cp [source file/folder] [target file/folder]
Examples:
Code:
cp /sdcard/bootanimation.zip /system/media/bootanimation.zip
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.
You could also type:
Code:
cp /sdcard/bootanimation.zip /system/media/
for the same effect.
Another example:
Code:
cp /sdcard/fonts/segoeui.ttf /system/fonts/DroidSans.ttf
will replace the default android font with segoeui, and rename segoeui.ttf to DroidSans.ttf so Android recognises it. Note that this can also be used to simply rename files by copying itself to itself
2.2.2 Move a file/folder
Type:
Code:
mv [source file/folder] [target file/folder]
This works the same as cp, except that it will move a file instead of copy it.
2.2.3 Remove a file/folder
Type:
Example:
Code:
rm /system/app/twitter.apk
This will remove the built-in twitter app from your system ROM.
2.3 Navigation through folders
Another basic of terminal usage
2.3.1 Changing Directories
You can easily change directory by using the cd command.
Once you are in a directory can access files and folder relatively
To change a folder type:
Code:
cd [absolute or relative folderpath]
Example:
will navigate to /system
2.3.2 List the contents of a directory
To see what's in a directory type or see the file information:
Code:
ls [directory/file]
OR while being in the directory type:
Example:
Code:
cd /sdcard/videos
ls
will navigate to /sdcard/videos and show what's inside it.
2.4 File Permissions
Once in a while permissions of files get corrupted. It does not happen alot, but sometimes it is necessary to correct them.
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)
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
To set the permissions on a file type
Example:
Code:
chmod 777 /system/fonts/segoeui.ttf
will make the segoeui.ttf file fully accessible by all users.
To check the currenct permissions of a file use the -l parameter of ls, example:
Code:
ls -l /sdcard/update.zip
will return the permissions and extra file info on the file.
2.5 Android Properties
A nice and fast way to see some android properties is Getprop. Just type:
and scroll through all the settings available in the .prop files aswell as running services.
You can manually set these settings with the setprop command.
Example:
Code:
setprop ro.modversion bananas
will set the Android version info to "bananas".
BE VERY, VERY CAREFUL WITH SETPROP, IF YOU SET SOMETHING WRONG IT MIGHT RUIN YOUR INSTALLATION AND EAT ALL YOUR COOKIES!
2.6 Writing output from a command to a file or the screen
For this echo is very useful. You use echo in this way
will return a line that says bananas
Now that itself is not very useful but combined with > it can send your text to a file.
Example:
Code:
echo bananas > /sdcard/bananas.txt
will make a txt file on your sdcard with bananas as content. Still not useful enough?
Try this:
Code:
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
This will set your CPU scaling_governor to performance (always 800Mhz). Note that this is not a recommended setting as it will wear your CPU out quickly and eat battery like the cookiemonster would eat... well cookies :P
Set it on ondemand using the same command:
Code:
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Good to know: Apps like SSSCFG set your scaling governor dynamically according to the state of your screen. It probably uses a similar script to set the governor (not 100% sure about this).
You can also write output from a command to a file with >
Example:
Code:
logcat > /sdcard/logcat.txt
will do a logcat and write it to a txt file on your SD card (useful for debugging problems)
NOTES:
* Commands and folders are CASE-SENSITIVE
* If a command completed succesfully, it will say nothing and start a new line.
* When you see a file does not have the correct permissions, start with giving it 777 to see if that's your problem. If you want you can make the permissions more strict later on.
... Since I have the "CyanogenMod" installed for me, I want many more programs such as an SSH-server (dropbear), wget ... available, the commands shown here should work even without this mod.
Bookmarks