So I have been reading quite a few threads here on XDA, and the one thing I noticed for noobs to linux/unix world is that they are struggling with some basic command once adb shell is gained. I decided to whip out this quick tutorial to help those noobs out to become more of an expert...like me...lol j/k
Here we go:
Prerequisites:
You must know how to invoke a adb shell command already to drop into your phone.
ALL commands in Unix/Linux are case sensitive
For more details, go to this ADB tutorial (very good one): http://forum.xda-developers.com/showthread.php?t=517874
Let's get going:
Once a shell is gained via adb, let's look at some of the basic commands you can do to navigate around the filesystem. Note: you must remove the double-quotes (") for the actual command.
Code:
"cd" = is change directory
to change to any directory, you type: cd dir_name (where dir_name is a full path)
Example: I want to go to /data/local/tmp in my phone, I would do
cd /data/local/tmp <hit ENTER>
You can also use the ".." to go UP one directory.
Example: I'm in /data/local/tmp and I want to go up to /data folder, a command would be: cd ../.. alternatively, if I do cd .. then i'll drop into /data/local folder instead.
Code:
"ls" = list files/directories
to list files/directories within a folder, the command should be:
ls <hit enter> => this will list all NON-HIDDEN file/directories within your CURRENT directory.
ls /data/local/tmp => this will list all NON-HIDDEN file/directories within /data/local/tmp directory.
ls -l => this will list all NON-HIDDEN file/directories within your CURRENT directory, plus additional details. Consider this is like a "Details" view in Windows Explorer.
ls -a => this will list all files/directories (including hidden files) within your CURRENT directory.
ls -la => this will list all files/directories (including hidden files) within your CURRENT directory, plus details.
Code:
"chmod" = change mode
Goes to wikipedia for more details: https://secure.wikimedia.org/wikipedia/en/wiki/Chmod
Most commonly used modes on android phones are:
"755" or "777".
So if you have a root.sh shell script that you downloaded from XDA, and uploaded to your phone and try to execute it with ./root.sh and it said "Permission denied". That means your script does not have the execute permission. You need to do:
chmod 755 root.sh <hit enter>
[B]IMPORTANT: There is *NO* negative sign (-) in front of the mode bit. So it is NOT chmod -755 root.sh[/B]
If you get a "File or directory not found" error, which means you are chmod-ing a file that doesn't exist in your current directory. To execute a chmod on root.sh in /data/local/tmp you do:
chmod 755 /data/local/tmp/root.sh
If you want to chmod an ENTIRE DIRECTORY and ALL files underneath it you do:
chmod -R 755 /data/local/tmp => this will set /data/local/tmp and ALL files/folders underneath it to be 755.
Code:
"chown" = change ownership
Go to wikipedia for details: https://secure.wikimedia.org/wikipedia/en/wiki/Chown
Most common used chown for android is: "root:root" or "root:shell"
Example: if you want to change ownership of root.sh to root:shell then you do:
chown root:shell root.sh
NOTE: the -R (recursive) option is also available for chown.
chown -R root:shell /data/local/tmp
Code:
"pwd" = print working directory
so when you are within a directory and you want to know which directory you are in, then you issue the command:
pwd <hit enter>
The system will reply back with the currently directory you are in.
I'll try to add more if I think of anything else useful, or if you have suggestions, please feel free to add.
so what does it mean to add adb to your path? thats holding me back from temp rooting on my mac. Im a total adb noob clearly.
hockey4life0099 said:
so what does it mean to add adb to your path? thats holding me back from temp rooting on my mac. Im a total adb noob clearly.
Click to expand...
Click to collapse
The easiest way to explain it is that you can run ADB from anywhere...do a search and you can find a more detailed (and more proper) explanation and directions on how to set it up.
hockey4life0099 said:
so what does it mean to add adb to your path? thats holding me back from temp rooting on my mac. Im a total adb noob clearly.
Click to expand...
Click to collapse
What OS are you using?
vboyz103 said:
What OS are you using?
Click to expand...
Click to collapse
mac
______________
hockey4life0099 said:
mac
______________
Click to expand...
Click to collapse
Like I said, do a search on XDA...there's a great guide on how to set up ADB properly. I'll link to it tomorrow when I get on the computer.
-- Sent from my 3VO Shooter --
hockey4life0099 said:
mac
______________
Click to expand...
Click to collapse
If you use mac, open a Terminal, and you should be at your home directory and type:
nano ~/.profile
if the .profile doesn't exist yet, then you'll see an empty.
Put this into the file
PATH=$PATH:/path/to/your/android/platform-tools
export PATH
save and exit out of Nano, and type:
source ~/.profile
then after this type adb and if adb is in your PATH then you see adb help.
Overview Of Permissions via ADB SHELL
Example = drwxrwxrwx
To Check Permission at anytime in ADB just Type:
ls -l
The First character defines the Directory, Link, Binary.
Below are some examples
Example = d---------
d = Directory
l = Link
b = Binary
The next 9 characters define the file permissions. These permissions are
given in groups of 3 each.
The first 3 characters are the permissions for the owner of the file or directory.
Example = -rwx------
The next 3 are permissions for the group that the file is owned by.
Example = ----rwx---
The final 3 characters define the access permissions for everyone not part of the group.
Example = -------rwx
There are 3 possible attributes that make up file access permissions.
r - Read permission. Whether the file may be read. In the case of a
directory, this would mean the ability to list the contents of the
directory.
w - Write permission. Whether the file may be written to or modified. For
a directory, this defines whether you can make any changes to the contents
of the directory. If write permission is not set then you will not be able
to delete, rename or create a file.
x - Execute permission. Whether the file may be executed. In the case of a
directory, this attribute decides whether you have permission to enter,
run a search through that directory or execute some program from that
directory
In addition to the file permission, you can also modify the owner and
group of the file. The chown program is used here and its syntax is very
simple. You need to be the owner of a file or root to do this.
Understanding Owner Permissions:
The first command is for owner ID, the Second Command is for Group ID.
exp. root.root ( First Root is owner, Second Root is Group ).
Chmod 644 some file, Like Build.prop For testing & then Veiw the Resulted Changes!
Refer to the table below as a quick reference.
Command Line for Both would look like this
chmod 644 build.prop = -rw-r--r--
\/
Chmod Guide
0 - ---
1 - --x
2 - -w-
3 - -wx
4 - r--
5 - r-x
6 - rw-
7 - rwx
SH Chown Guide
\/
chown root.root build.prop
root.root = Root
root.shell = Shell
Busybox SH Chown Guide
\/
chown 0.0 build.prop
0.0 = Root
0.2000 = Shell
I'll update the chmod with more with More Complex Commands Later
Side Note:Always set owner ( chown ) before Setting Permissions ( Chmod )!
Hope this Clears up things & is Helpful to everyone
~Eugene373
Add adb to your path in Windows.
As has been explained above all it does is allowing your adb to be called out from any location.
To set it in windows you will need to add path to your adb.exe file to your PATH in widows XP or CLASSPATH in windows7.
You can find it in start->contro panel->system->advanced.
There is a tab called "Inviromental Variables".
Click on that tab and new window will pop up. New window has 2 field in it. We are interested in bottom field called "System variables".
Windows XP user should look for line with variable "Path".
Click that line and choose edit below. New pop up will apear and you can edit path line in there. You should add path to your adb.exe to that line.
Example.
I did install windows sdk in c:\android\android-sdx-windows so my adb.exe file is in that folder. I did add path to that folder in "Paht" line of system variables. Add path to your adb.exe after semicolon.
;c:\Location\of folder\where you have\adb exe file\
Save changes, apply them. Now you can use call for adb commands from any location.
Widows 7 users.
Same changed need to be appied as for Windows XP.
There is only one difference that that path in Inviromental variables in windows7 is called "CLASSPATH".
Rest is same. Just add the path to folder containing your adb.exe file to CLASSPATH line and you would be able to use adb in any location.
Hope this make sense and will help.
My mac keeps sayin no device but I can access adb from anywhere basically its in my path but won't pick up my phone
Sent from my PG86100 using XDA Premium App
snoopy1e11 said:
My mac keeps sayin no device but I can access adb from anywhere basically its in my path but won't pick up my phone
Sent from my PG86100 using XDA Premium App
Click to expand...
Click to collapse
Make sure your phone is in debugging mode.
ADB won't see phone if debugging is not enabled.
It is on
Sent from my PG86100 using XDA Premium App
I'm a windows user.
Can't think of anything else.
Sorry.
agat63 said:
Make sure your phone is in debugging mode.
ADB won't see phone if debugging is not enabled.
Click to expand...
Click to collapse
If you have USB debugging turned on, you should see a triangle with exclamation mark on task bar. Secondly, try to do this:
adb kill-server => kill off current server first
then
sudo adb devices => u need to enter password
Basically, you are running adb with escalated privilege, sometimes it needs root access.
This is Wat I got
Sent from my PG86100 using XDA Premium App
snoopy1e11 said:
This is Wat I got
Sent from my PG86100 using XDA Premium App
Click to expand...
Click to collapse
hmmm interesting...just wondering if you have your device turned on to be disk usage instead of just Charge Only?
Check on your desktop to see if you SD card had mounted, not sure if it makes a difference but worth a try. Another thought is that maybe your USB port doesn't work?? Did you check your phone to see if you have a triangle with exclamation mark in it on the task bar? (to the left)
Also, try it on a different computer if u can, and if it still doesn't work, afraid urs is defective.
I really appreciate ur help I re did the sudo command and hit "adb devices connect" and my device popped up
Sent from my PG86100 using XDA Premium App
snoopy1e11 said:
I really appreciate ur help I re did the sudo command and hit "adb devices connect" and my device popped up
Sent from my PG86100 using XDA Premium App
Click to expand...
Click to collapse
Ha, interesting cuz I never have to issue that command. Good to know you got it to work.
I am adding some mod files and tweaks to an android 2.3.3 image. It is a Livesuit flashable image for the Alpha 2 Skypad. I use unimg.exe to extract the files then fileaddsum and unimg to repack the file under Windows.
I mount the extracted image in Linux Mint then make my changes. I have tried different tricks people have suggested to set the permissions of the file, but whenever I umount and repack the img, it will install, but I have to go into adb and chmod the files. I have written a simple command file so it only take a second, but being new to Linux I am not finding any way to set the permission when I copy over the files to the mounted image.
Any suggestions/ Thanks in advance.
bump..........................................
re-bump .............................................
Not sure if this will help, but in unix permissions are set with chmod. so to ad the exicutable permission you enter:
Code:
su
chmod a+x filename
exit
However if youve had suggestions on setting permissions, you must already know this?
matts95 said:
Not sure if this will help, but in unix permissions are set with chmod. so to ad the exicutable permission you enter:
Code:
su
chmod a+x filename
exit
However if youve had suggestions on setting permissions, you must already know this?
Click to expand...
Click to collapse
That wasn't working for me. But I found a cheat, I guess you could say. Once the image was open I would pull the files from the emulator or a pad directly to the image+folder. Not elegant but it worked.
Hi All
Can someone please tell me how to set permissions, I mainly do theming, but in theming sense 4.0 I had to boot idlescreek.apk out of the rom because it caused just a blank screen at start up.
If anyone is willing to give me a brief tutorial, or direct me to a URL that deals with that subject I would be most thankful.
Have fun today
Its in recovery and 4ext app for me and also in cwm app
THISIS50.COM IF IT'S HOT IT'S HERE
for a particular file, you could always just use adb. For example SystemUI.apk:
Code:
adb shell chmod 0644 /system/app/SystemUI.apk
then just change the file name and permissions to fit your needs.
netwokz said:
for a particular file, you could always just use adb. For example SystemUI.apk:
Code:
adb shell chmod 0644 /system/app/SystemUI.apk
then just change the file name and permissions to fit your needs.
Click to expand...
Click to collapse
Isn't it chmod 0744?
ssojyeti2 said:
Isn't it chmod 0744?
Click to expand...
Click to collapse
could be, I'm not that sure actually when it comes to permissions this way. I've only followed the syntax a few times. But I've never had a problem with this and system apps.
I accidentally (sure!) removed all permissions on a folder in / so now the system can't even read it to display it in root explorer. Any way I can fix it? I've searched pretty hard and tried chmod and a couple other ideas in the terminal but nothing so far has worked.
Edit: Sry, didn't read properly. Please tell me which folder in / you removed all permissions from so I can look them up. The following commands with the given permissions should work though, but you have to replace / with the correct path to the folder.
Try it again with chmod:
Code:
su
chmod 755 /
"ls -ld /" should now show the flags "drwxr-xr-x".
Sent from my SGS2
Blacktremolo said:
Try it again with chmod:
Code:
su
chmod 755 /
"ls -ld /" should now show the flags "drwxr-xr-x".
Sent from my SGS2
Click to expand...
Click to collapse
That's what I tried. See the actual path is /.bak but when I chmod for that path, since it has no permissions, it says no such file or directory.
Even if it has no permission set u are able to operate on it with chmod. Please post the Output of "ls -ld /.bak"
If that also says "no such file or directory" then there simply is "no such file or directory"
Sent from my SGS2
Or are you maybe refering to a file in /mnt/sdcard (the internal user memory)?
Sent from my SGS2
Blacktremolo said:
Even if it has no permission set u are able to operate on it with chmod. Please post the Output of "ls -ld /.bak"
If that also says "no such file or directory" then there simply is "no such file or directory"
Sent from my SGS2
Click to expand...
Click to collapse
I suppose it's not there. I had created the folder last night to store a few backups of files but when I woke up this morning the entire folder was missing. I'm not sure. ls reported no such file or directory. I guess there just isn't one. Thanks for the help. I'll hit the buttons.
I guess the problem is that / is mounted read-only.
Sent from my SGS2
I need to batch apply a set of permissions to these two folders and all files contained within. I'm moving my ringtones to these so that they preserve upon an SD Unmount, but I need to know the proper command in Terminal Emulator to do so. The files need rw-r-r-
/system/media/audio/ringtones
/system/media/notifications
Any help on this would be greatly appreciated.
if you want to apply a permission to the folder and also(recursive) to all of its contents...
you can use this:
su -c chmod -R 777 /path/to/directory
NOTE: 777 = rwx-rwx-rwx