Minggu, 08 Desember 2013

Basic Linux/Unix Shell Commands - Android


CATATAN = Semua perintah di linux / unix CASE SENSITIVE (Sangat Sensitif)
penjelasan semua pake inggris kalo ga ngerti pake translate,,,



To change to any directory, simply type:

cd dirname   

dir name is the path. For instance, to switch to system/etc, type:

cd /system/etc

'..' will allow you to go back one directory. In our example, typing:

cd

..would take you back to /system

ls - List Files
To list all the files in whatever directory you're in, simply type:

ls

pressing enter after, of course. This will list all NON-HIDDEN files/directories.

ls /system/etc

will list the contents of system/etc

ls -l 

will list all NON-HIDDEN files in your current directory with additional details

ls -a 

will list all files/directories(including hidden) within your current directory

su - SuperUser
The standard adb shell (unless you're on an insecure kernel/ramdisk), will be a non-root shell ($)
To obtain root priviliges (if your phone is rooted), simply type:

su

on obtaining superuser priviliges, you will be presented with a # symbol, which represent a root shell.

chmod - Change Mode
The two most commonly used 'modes' you'll come across in Android are '777' and '755' 
These numerical pemissions have different meanings, of course.
This can be a little confusing, so I hope this explains it in a simple to understand way.
As you can see, there are three numbers in the following example;
'chmod 755'
So, to break that down: The first number in the sequence, '7', represents the USER (aka, you).
The second number in the sequence, '5', represents the GROUP (users who are members of the file's group) and the third number, '5' represents OTHERS (aka, everyone else). 
Now to explain why they are 755, and the significance of those numbers, see the following list:

7     Full
6     Read/Write
5     Read/Execute
4     Read Only
3     Write/Execute
2     Write Only
1     Execute
0     None

So in the instance of 777, you can see that USER, GROUP and OTHERS have FULL access to the file in question.
To change the permissions of one file apns-conf.xml for example, type:

chmod 777 /system/etc/apns-conf.xml

To change the permissions of all files in a directory, use the -R (recursive)option:

chmod 777 -R /system/etc

pwd - Print Working Directory

Couldn't be more simple. if you want to find out which dirctory you're currently in, type:

pwd

and press enter. 

cat - Concatenate (evolved from)

The cat command if used to list a file's contents on your screen; or pass via pipeline to use with other Linux commands.

cat /proc/mounts

will output the various mount points in your android OS. 
Note that there are many other uses for the cat command.
It can be used to copy files, for example. 

dd - Data Dump
This one's useful if you're ever looking to dump your ROM/kernel, etc.



dd if=/dev/block/mmcblk0p1 of=/sdcard/system.img bs=4096 

There you go - system.img is now on your SD card!

mount - As it says on the tin.



su
mount -o rw,remount /dev/block/mmcblk0p1 /system

Note - you will see many variations of this.
Just keep it simple like the command above.
You don't need to specify the file system type, for example. 

Tidak ada komentar:

Posting Komentar