14

I am trying to give access to a file I have written in one app to another app. chgrp is not available in the adb shell (command 'chgrp' not found) I have installed BusyBox but in order to get access to chgrp.

For example I use the command chown app_79 file.txt and it works. But when I try chgrp app_79 file.txt it always returns something like chgrp: unknown group app_79

I Googled a bunch and found that most linux systems have a file /etc/group which stores the group information for that system, but it is not present in Android.

Matt
  • 985
  • 2
  • 9
  • 22

3 Answers3

24

Using the builtin tools, rather than busybox, it would be

chown uid.gid filename

Probably with these id's having to be numeric as Matt pointed out.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117
  • The ids did NOT have to be numeric for me. `root.root` and `root.system` worked for instance on my device. – BuvinJ Jun 01 '16 at 21:56
  • Note that in Linux `chown owner:group filepath` generally works vs this period syntax. – BuvinJ Jun 01 '16 at 21:58
7

Use busybox chown uid.gid file.txt and specify UID and GID as numbers instead of names. app_79 likely corresponds to ID 10079 (to be sure you may recheck it with busybox ls -l -n /data/data):

busybox chown 10079.10079 file.txt
Volo
  • 28,673
  • 12
  • 97
  • 125
5

Found some information here about how some group ids are hardcoded. I also had previous knowledge that /data/system/packages.list and /data/system/packages.xml contained the UIDs of apps, which are all something like 10000+x. What I now know is that x is the number that comes after "app_" when you ls -l.

So, the weird thing is you can chgrp 10079 file.txt but you cannot chgrp app_79 file.txt.

Hope this helps someone.

Matt
  • 985
  • 2
  • 9
  • 22