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!
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.
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.
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
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.
Now start the Windows command line ...
... and can now run the following commands.
# change in folgndes Directory
# display ADB-Help
# shows the connected Android devices
# Android will be re-launched
# Android will be started in recovery mode
# start the Android-shell
adb reboot recovery
# 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
# installed an app from your PC
adb logcat -b events
# 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)
# a TCP port of Android directly connect to a TCP port of our operating system
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
In the CyanogenMod - wiki, there are other useful commands:ADB - CyanogenMod Wiki
adb forward tcp:5901 tcp:5901
--- 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 :-)
# shows who you are ;-)
cat lall.txt > lall_copy.txt
# displays the running processes
# shows the system utilization
# shows all mounted partitions
# grep filters e.g. Expenditure
# root privileges (su = substitute user)
mount | grep system
# 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
cp [source file/folder] [target file/folder]
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.
cp /sdcard/bootanimation.zip /system/media/bootanimation.zip
You could also type:
for the same effect.
cp /sdcard/bootanimation.zip /system/media/
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
cp /sdcard/fonts/segoeui.ttf /system/fonts/DroidSans.ttf
2.2.2 Move a file/folder
This works the same as cp, except that it will move a file instead of copy it.
mv [source file/folder] [target file/folder]
2.2.3 Remove a file/folder
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:
cd [absolute or relative folderpath]
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:
OR while being in the directory type:
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
To set the permissions on a file type
will make the segoeui.ttf file fully accessible by all users.
chmod 777 /system/fonts/segoeui.ttf
To check the currenct permissions of a file use the -l parameter of ls, example:
will return the permissions and extra file info on the file.
ls -l /sdcard/update.zip
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.
will set the Android version info to "bananas".
setprop ro.modversion 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.
will make a txt file on your sdcard with bananas as content. Still not useful enough?
echo bananas > /sdcard/bananas.txt
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
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Set it on ondemand using the same command:
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).
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
You can also write output from a command to a file with >
will do a logcat and write it to a txt file on your SD card (useful for debugging problems)
logcat > /sdcard/logcat.txt
* 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.