我应该在哪里安装Toybox? -- installation 领域 和 file-system 领域 和 command-line 领域 android 相关 的问题

Where should I install Toybox?


3
vote

问题

中文

我拥有一个rooted三星galaxy s继承4g运行股票和roid4.1.2。

如果您有Android 6.0"Marshmallow" 或更好,那么您有 toybox 。这是一包命令行工具,为有时使用终端仿真器的高级用户提供方便。不幸的是,Android 4.1.2不包括Toybox。相反,它包括一些与使用不太好的工具。

有时我使用杰克帕维奇写的终端仿真器;其他时候,我使用 adb shell 从笔记本电脑。

  1. 将toybox安装到我的系统分区或我的数据分区时会更有意义吗?两个分区都有足够的自由空间。

  2. 当Android和ToyBox提供命令时,我希望Toybox版本获胜。在Linux上,我可能会将Toybox安装到 /home/unforgettableid/bin /usr/local /opt 。您能否在我的手机上建议我建议一个明智的地方,以安装Toybox(以及它的大量符号链接)?

[编辑:我想知道各种busybox安装程序是否是多少。此外,我想知道Android如何设置路径环境变量。同样,我也想知道是否有办法改变该变量并使我的更改跨重启。最后,我想知道是否在我的路径中首先将玩具箱工具放在我的路径中可能会以非明显的方式打破东西。]


可能相关:"Android文件夹层次结构"

英文原文

I own a rooted Samsung Galaxy S Relay 4G running stock Android 4.1.2.

If you have Android 6.0 "Marshmallow" or better, then you have Toybox. This is a package of command-line tools, handy for advanced users who sometimes use a terminal emulator. Unfortunately, Android 4.1.2 does not include Toybox. Instead, it includes some other tools which aren't as nice to use.

Sometimes I use the terminal emulator written by Jack Palevich; other times I use adb shell from a laptop.

  1. Would it make more sense to install Toybox to my system partition, or to my data partition? Both partitions have far more than enough free space.

  2. When a command is provided both by Android and by Toybox, I want the Toybox version to win. On Linux, I might install Toybox to /home/unforgettableid/bin or /usr/local or /opt. Could you please suggest a sensible place for me to install Toybox (and its large collection of symlinks) on my phone?

[Edit: I wonder what the various BusyBox installers do. Also, I wonder how Android sets the PATH environment variable. As well, I also wonder whether or not there's a way for me to change that variable and to make my change persist across reboots. Finally, I wonder whether or not putting the Toybox tools first in my PATH would be likely to break things in non-obvious ways.]


Possibly related: "Android Folder Hierarchy".

        

回答列表

5
 
vote

我应该在哪里安装Toybox?

将Toybox安装到我的系统分区或我的数据分区时会更有意义吗?

取决于。如果您不打算再次恢复出厂重置手机,可以选择数据分区,否则,选择"系统分区" 。

当Android和Toybox提供命令时,我希望Toybox版本获胜。

path 变量包含包含可执行二进制文件的目录的位置。如果您决定保留单独的目录,请为您的符号链接,配置$ path以首先将命令搜索到目录中。如果它找到一个,它将执行它。

在Linux上,我可能会将Toybox安装到 /home/unforgettableid/bin /usr/local /opt 。您能否在手机上建议我为我安装Toybox(以及它的大量符号链接)的明智的地方?

所有这些位置都不存在于Android。由于您使用的是Android 4.1.2,我假设您将使用具有FAT文件系统格式化的外部SD卡。 Symlinks不适用于FAT文件系统(至少在FAT32或VFAT上至少),因此您最好的选择是在 /data /system

或者,您可以在外部SD卡下进行图像,使用Android内核支持的文件系统(通常ext2 | ext3 | ext4)格式化图像,然后将其安装在环回模式下的任何位置。我虽然没有尝试过这种方法。

我想知道各种Busybox安装程序是否如何

busybox(由Stericson )放置 Busybox 二进制进入 /system/xbin 并创建 symlink for它的小程序在同一目录下的二进制文件。

也,我想知道Android如何设置路径环境变量。同样,我也想知道是否有办法改变该变量并使我的更改跨重启持续存在

我不知道何时android设置$ path。但是,您使用的shell很可能是具有配置文件。

  • mksh mirbsd korn shell ; 默认shell 在Android上)有一个配置文件 data/misc/wifi/wpa_supplicant.conf0 在<代码> data/misc/wifi/wpa_supplicant.conf1 。您可以在那里设置$ path,更改将持续跨重启。
  • for bash shell,配置文件 data/misc/wifi/wpa_supplicant.conf2 位于 data/misc/wifi/wpa_supplicant.conf3

似乎两个文件都是仅适用于互动会话,所以如果您尝试使用adb来访问未在<代码>置于Toybox或其符号链接data/misc/wifi/wpa_supplicant.conf4 ,<代码> data/misc/wifi/wpa_supplicant.conf5 ,<代码> data/misc/wifi/wpa_supplicant.conf6 ,<代码> data/misc/wifi/wpa_supplicant.conf7 或<代码> data/misc/wifi/wpa_supplicant.conf8 ($ path中的默认位置),您将收到"命令:未找到" 错误。这是因为默认的$路径将被使用。

我还没有找到这个问题的解决方案,但请参阅此答案下面的评论。

无论如何,让我们现在安装Toybox。


如何在Android设备上安装Toybox?

注意:解决方案假定您的android rooted,即 adb 是在PC中设置的,并且您的设备连接到带有 USB调试启用。

安装到系统分区

如果选择标准位置,则不需要在$ PATH中的变化。 BusyBox更喜欢 Abcdefghijklmnabcdefghijklmn19

  • 重新安装在 RW 模式中的系统分区。 如果需要,请参阅无法重新汇编/系统在RW
  • 警察 toybox 二进制文件到 network0 并为其提供可执行权限。 (为其他二进制文件设置的默认权限是 network1 。)

    可以使用 chmod

      network2  
  • Toybox 二进制提供的各种工具创建符号链接。这取决于你如何创建它们。

    我使用了一个非常简单的方法,但它需要一个* nix system

      network3  

    我在这里正在做的是执行 toybox 二进制文件,用新行替换空白空格,以便在新行中显示每个工具。稍后我删除了最后一行(它在输出中是空白的),删除运输返回方便的 Toybox 二进制创建一个符号链接。

    如果您在PC中没有* nix操作系统,则可以使用此方法:

      network4  

完成!您的Toybox及其小程序已准备好执行。

安装到数据分区

  1. network5 下创建一个目录( network6 hustheforth)
  2. toybox 二进制文件复制到 network7 并为其提供可执行权限。 (为其他二进制文件设置的默认权限是 network8 。)

      network9  
  3. Toybox 二进制提供的各种工具创建符号链接。这取决于你如何创建它们。

    我使用了一个非常简单的方法,但它需要一个* nix system

      network={     ssid="Telekom"     key_mgmt=NONE     priority=42 } 0  

    只有位置发生了变化,其余过程是一个在系统分区中安装的一个过程

  4. 编辑默认shell的配置文件并添加

      network={     ssid="Telekom"     key_mgmt=NONE     priority=42 } 1  

    这将导致shell调查 network={ ssid="Telekom" key_mgmt=NONE priority=42 } 2 首先执行二进制,如果可用。

完成! 享受您的玩具箱及其小足。

 

Where should I install Toybox?

Would it make more sense to install Toybox to my system partition, or to my data partition?

Depends. If you don't plan to factory reset the phone ever again, you can choose data partition, else, choose system partition.

When a command is provided both by Android and by Toybox, I want the Toybox version to win.

The PATH variable contains the location of the directories containing executable binaries. Should you decide to keep a separate directory for your symlinks, configure $PATH to search for a command into your directory first. If it finds one, it will execute it.

On Linux, I might install Toybox to /home/unforgettableid/bin or /usr/local or /opt. Could you please suggest a sensible place for me to install Toybox (and its large collection of symlinks) on my phone?

All those locations don't exist for Android. Since you're using Android 4.1.2, I suppose you would be having your external SD card formatted with a FAT filesystem. Symlinks don't work on FAT filesystems (not on FAT32 or vfat at least) so your best bet is to install under /data or /system.

Alternatively, you can make an image under your external SD card, format that image with a filesystem supported by your Android's kernel (often EXT2 | EXT3 | EXT4), then mount it in the device anywhere in loopback mode. I've not tried this method though.

I wonder what the various BusyBox installers do

Busybox (by Stericson) places the busybox binary into /system/xbin and creates symlink for its applets to its binary under the same directory.

Also, I wonder how Android sets the PATH environment variable. As well, I also wonder whether or not there's a way for me to change that variable and to make my change persist across reboots

I do not know when Android sets up $PATH. However, the shell you're using would most likely be having a configuration file.

  • mksh (MirBSD Korn Shell; the default shell on Android) has a configuration file mkshrc in /system/etc. You can set $PATH there and the change would be persistent across reboots.
  • For bash shell, the configuration file is bashrc located under /system/etc/bash.

It appears that both files are meant for interactive sessions only, so if you attempt to use adb for accessing a Toybox or its symlink which is not placed under /sbin, /vendor/bin, /system/sbin, /system/bin or /system/xbin (the default locations in $PATH), you would receive a "COMMAND: not found" error. This is because the default $PATH would be used instead.

I've not found a solution for this problem yet, but see the comments below this answer.

Anyhow, let's install Toybox for now.


How do I install Toybox on an Android device?

Note: the solution assumes that your Android is rooted, that adb is setup in PC, and that your device is connected to a PC with USB debugging enabled.

Installation into system partition

No change in $PATH is required if you choose a standard location. Busybox prefers /system/xbin.

  • Remount the system partition in rw mode. If required, see Can't remount /system in rw
  • Copy the toybox binary to /system/xbin/ and give executable permission to it. (The default permissions set for other binaries is rwxr-xr-x.)

    You can do so using chmod

    adb shell su -c "chmod 755  /system/xbin/toybox" 
  • Create symlinks for various tools accessible by toybox binary. It is up to you how you create them.

    I used a very simple method, but it requires a *nix system

    adb shell toybox | sed 's/\ /\n/g' | head -n -1 | tr -d '\r' | while read line; do adb shell su -c 'ln -sf /system/xbin/toybox "/system/xbin/$line"'; done 

    All I'm doing here is executing the toybox binary, replacing the white-spaces with a new line so that each tool shows up in a new line. Later on I'm removing the last line (it was blank in output), removing carriage return conveniently put by adb, and then for each line of output I'm creating a symlink to toybox binary with the name of the tool, in the same directory.

    You can use this method if you don't have a *nix OS in PC:

    adb shell su toybox | toybox sed 's/\ /\n/g'| toybox sed '$d'| while read line; do  toybox ln -sf /system/xbin/toybox /system/xbin/$line; done 

Done! Your Toybox and its applets are ready to be executed.

Installation into data partition

  1. Create a directory under /data (/data/my_bin henceforth)
  2. Copy the toybox binary to /data/my_bin and give executable permission to it. (The default permissions set for other binaries is rwxr-xr-x.)

    adb shell su -c "chmod 755  /system/xbin/toybox" 
  3. Create symlinks for various tools accessible by toybox binary. It is up to you how you create them.

    I used a very simple method, but it requires a *nix system

    adb shell su -c "/data/my_bin/toybox" | sed 's/\ /\n/g' | head -n -1| tr -d '\r'| while read line; do adb shell su -c "ln -sf /data/my_bin/toybox '/data/my_bin/$line'"; done 

    Only the location has changed, the rest of the procedure is alike to one followed for installation in system partition

  4. Edit your default shell's configuration file and add

    PATH=/data/my_bin:$PATH  

    This would cause the shell to look into /data/my_bin first and execute the binary, if available.

Done! Enjoy your Toybox and its applets.

 
 
     
     
0
 
vote
vote
最佳答案
 

如果您的Android版本用Toybox和一些Toybox Symlinks船舶,则可以将其中的 /system/bin 留出。但是,如果您自己安装了Toybox,则将新鲜安装的Toybox和所有符号链接均最为妙,在 /system/xbin 中。

让我解释原因。

因为答案中的fireelord指出: adb shell 启动一个交互式shell。但是 adb shell ls 等命令启动一个非交互式shell。对于性能原因< / a>,非交互式shell永远不会读取任何配置文件。因为它们没有读取任何配置文件,他们的 search path 硬编码。< / p>

很高兴有玩具箱甚至是非交互式炮弹;事实上,如果它对这种贝壳不可用,它可能会令人困惑。所以你肯定想将Toybox安装到搜索路径上的位置。

但您可能不希望在搜索路径中提前将Toybox符号链接放在Seand android的 cp ls 等基本实用程序。我从未检查过,但我理论您的版本的Android可能包含应用程序,依赖于库存Android命令行实用程序的怪癖。要了解更多信息,请参阅此帖,其中android命令行工具维护者解释为什么Android必须坚持其非Toybox Abcdefghijklmnabcdefghijklmn6 几个月。

大多数库存Android命令行实用程序是 /system/bin 。唯一跌落于股票的Android shell搜索路径的目录是 /system/xbin

这就是为什么您可能想要将Toybox放入 /system/xbin 中的所有符号链接。


提示:如果需要,您可以创建一个shell脚本,只需将其所有参数传递给Toybox。您可以为此shell脚本提供超短名称,例如 /system/xbin0 。这使得您可以更轻松地要求您的设备应该运行Toybox玩具而不是Stock Android命令。例如,要运行Toybox Abcdefghijklmnabcdefghijklmn11 ,只需输入 /system/xbin2

 

If your Android version ships with Toybox and some Toybox symlinks, you can leave those in /system/bin. But, if you're installing Toybox yourself, it might be wisest to put the freshly-installed Toybox, and all its symlinks, in /system/xbin.

Let me explain why.

As Firelord points out in his answer: adb shell starts an interactive shell. But commands such as adb shell ls start a non-interactive shell. For performance reasons, non-interactive shells never read any config files. Because they don't read any config files, their search path is hardcoded.

It's nice to have Toybox available even to non-interactive shells; in fact, if it's unavailable to such shells, it can be confusing. So you definitely want to install Toybox to a location which is on the search path.

But you might not want to put the Toybox symlinks any earlier in the search path than Android's cp, ls, and other basic utilities. I've never checked, but I theorize that your version of Android might include apps which depend on quirks of the stock Android command-line utilities. To learn more, see this post, in which the Android command-line tools maintainer explains why Android had to stick with its non-Toybox ls for some months.

Most of the stock Android command-line utilities are in /system/bin. The only directory which falls later in the stock Android shell's search path is /system/xbin.

That is why you may want to put Toybox and all its symlinks in /system/xbin.


Tip: If you want, you can create a shell script which simply passes all of its parameters to Toybox. You can give this shell script an ultra-short name such as t. This makes it easier to request that your device should run a Toybox toy instead of a stock Android command. For example, to run Toybox ls, simply enter t ls.

 
 
     
     

相关问题

6  我如何在Android上安装Firefox,没有服务或Google帐户?  ( How can i install firefox on an android with no service or google account ) 
这是一个非常窄的用例,手机只用作移动GUI环境。手机没有服务且与Google帐户无关,因此无法访问Google Play。是否有另一种方式安装Firefox? ...

125  我可以在我的非Android设备上安装Android吗?  ( Can i install android on my non android device ) 
许多人想要尝试/使用Android而不购买新的Android手机。如何在运行诺基亚Symbian,Maemo或MeeGo的当前手机或设备上安装Android; Microsoft Windows Mobile或Windows Phone 7/8/10; Apple iOS(iPhone); RIM的BlackBerr...

1  我正在努力下载蓝kik,但它一直在给我'未安装的应用程序'消息  ( Im trying to download blue kik but it keeps giving me the app not installed ) 
我正在使用一个tcl lx(我不会怀疑是问题,因为手机有多糟糕),我正在寻找一个简单的解决方案。我尝试多次安装它,删除和重新下载APK,但似乎没有任何工作。 ...

48  如何在我的Android设备上安装Google Apps包(播放商店,......)?  ( How can i install the google apps package play store on my android device ) 
我最近安装了一个自定义ROM,找不到播放商店。似乎缺少属于谷歌的所有应用。 如何在我的Android设备上安装Google Apps包(播放商店,......)? ...

5  Google Play无法使用RPC安装应用程序:S-5:AEC-0  ( Google play fails to install application with rpcs 5aec 0 ) 
有人报告说,我无法在Google Play上安装或升级应用程序。它与错误RPC:S-5:AEC-0 失败 这是什么意思?如何解决这个问题? ...

3  手动安装Split APK  ( Install split apk manually ) 
最近我必须知道一个名为split apks的东西,并发现切片作为无效的apk文件,只有基础是。不幸的是,这意味着通常的默认包安装程序无法处理此操作,因此我必须知道另一件名为SAI的东西,一个拆分APK安装程序,能够与或没有root工作。然而,好奇,我想知道它是如何在内部工作的,并开始做一些研究。我没有走得太远,但我必...

0  是否有可能通过PC从Google Store安装/更新应用程序?  ( Is it possible to install update apps from google store via pc ) 
几个月前,我被迫卸载一些应用程序以更新其他应用程序。最近我丢失了通过Gmail接收电子邮件通知的能力(然而,搜索工作)。所有因为垃圾应用程序Google Play和Google Play服务,不断增长。我计划完全卸载它们,至少重新恢复我手机前期前2年的功能。 但是,如果我必须进行一些应用程序的更新,或者我想安装新的应...

2  重新安装设置应用程序。  ( Re install settings application ) 
我已经编译了android源代码并获得settings.apk现在我想知道我可以在手机上安装该应用程序吗?当我尝试这样做的时候,我的手机说"无法安装应用程序" 我可以做什么来安装该应用程序? ...

1  安装循环Android 4.4.2 Galaxy Core II  ( Install loop android 4 4 2 galaxy core ii ) 
昨天我收到了我的三星Galaxy Core II(SM-G355HN)的更新。我下载了更新并试图安装它。我收到了大约94%,我收到了 error code [6] in cache/fota/update.zip 。我试图做一个硬重置,但我无法进入恢复模式。当安装失败时,我的手机将重新启动两次,一次只需屏幕,即 Sa...

13  试图安装新应用时“存储不足”  ( Insufficient storage when trying to install new app ) 
每次安装新应用程序时,我都会收到消息"不足" ,无法安装 ! 我正在使用三星gt19060我的内存是8GB。我还没有下载任何东西,但随时我试图下载它会告诉我低内存空间。 ...

18  没有网上安装Android应用程序是否有任何方法?  ( Is there any way to install android app without having internet ) 
我刚买了三星Galaxy Mini S,但我没有3G或Wi-Fi Internet - 我只在我的电脑上有互联网。是否有任何方法可以通过蓝牙或使用USB电缆安装Android应用程序,或使用USB电缆? (我的电脑上有蓝牙)。 如果可以安装应用程序,而不是下载应用程序的应用程序?市场不会让我将它们下载到我的电脑。 ...

1  在Nexus 7(2013)平板电脑上升级Android 4.3至4.4.2时出错  ( Error when upgrading android 4 3 to 4 4 2 on nexus 7 2013 tablet ) 
我有一个全新的Google Nexus 7(2013)LTE平板电脑和我所做的第一件事,是检查我的设备是否有任何SYS更新。它是。系统报道了4.3 - &gt; 4.4.2更新已准备好下载和安装。 但是,更新和击中按钮安装后,我收到了 Error 消息和一个droid说谎图标。在此之后,我的平板电脑已重新启动并恢复...

0  阻止应用程序安装在AVD环境中?  ( Blocking apps to be installed in avd environment ) 
开发人员是否可能阻止他们的Google Play应用程序在AVD安装,或者我只是选择不支持的AVD配置文件?我正在尝试将应用程序安装到AVD并在更受控的环境中调试,但是,它说: 您的设备与此版本不兼容 所以,它不是错误消息。在安装应用程序之前它是Google播放消息。 ...

4  储存不足,即使是用于内部空间和充足的空间格式化的棉花糖SD卡  ( Insufficient storage even with marshmallow sd card formatted for internal space ) 
当我尝试从播放商店安装一个应用程序时,我得到"存储不足" 消息,但我的SD卡上有20 GB,该卡格式化了内部存储。我正在使用Moto第2代。为什么我不能安装新的应用程序? ...

21  为什么我有足够的存储时无法安装应用程序?  ( Why cant i install apps when i have enough storage ) 
在"设置" &gt; "SD卡和amp;电话存储设置" 在"内部电话存储" 下,它将"可用空间" 列为13.78MB。我正在尝试安装2.38MB的应用程序。为什么我会得到"可用的不足" 错误消息?我显然有足够的空间。 如果它是相关的,我的手机就是LG Optimus v。 ...




© 2021 it.wenda123.org All Rights Reserved. 问答之家 版权所有


Licensed under cc by-sa 3.0 with attribution required.