0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nox_adb shellでchgrpする

Posted at

背景

NoxPlayerのIceCreamSandwich環境でUWSCマクロを書こうとしたとき、nox_adb shell環境では最初からls,grep,cp,chmod等のUNIX系コマンドは通る。
そのため、NoxのAndroid環境ではBusyBoxのコマンド群が予め/system/bin/shに含まれていたのではないかと勘違いしていた。

しかしながら、ファイル・ディレクトリのグループ情報を変更するときにchgrpしようとすると

nox_adb shell
# chgrp gip filename
# /system/bin/sh: chgrp: not found

と出てしまい、グループ情報が変更できないことがわかった。そのためchgrpを使う方法を2つ考えた。

解決方法1:BusyBoxを入れる

Nox側でroot取って、ここからアプリをインストール、アプリを開いてBusyBoxをインストール。
画面の指示通りにインストールしたなら、nox_adb側で

nox_adb shell
# cd /system/xbin
# alias busybox="`pwd`/busybox"

と打ち込めば、chgrpを含め,vi,tar等も通るようになる。

なお、adb shellに関して公式のドキュメントを見てもls以外の記述はなく、何のコマンドが最初から使えるかわからないがここを見る限り、Androidのバージョンによっては、adb shell環境ではgrep,cp,chmodが最初から使えないのもありそう。
ただし、手持ちのOreo機種ではchgrpコマンドも含め、いずれのコマンドも通ったので、Androidバージョンによって通ったり通らなかったりするコマンドがあるみたい。

解決方法2

chownなら問題なく通るため、以下のようにグループ情報を変更する事ができる。

chown uid.gid filename

chgrpするだけならこっちのほうが簡単。

教訓

adb shellするならBusyBoxを最初から入れたほうがいい。

参考

Androidのターミナルを強化する『BusyBox Non-Root』
How to change the group id of a file on rooted android device?
Android Debug Bridge(adb)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?