Skip to content

pegasusheavy/armybox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸͺ– Armybox

Crates.io docs.rs License Build Status

A memory-safe #[no_std] BusyBox/Toybox clone written in Rust.

πŸ“– Documentation Β· πŸ“¦ Crates.io Β· πŸ”§ API Docs

✨ Features

  • 293 applets β€” 100% Toybox compatible + 55 additional utilities
  • Multi-call binary β€” single executable providing all utilities
  • Pure Rust 2024 β€” memory-safe implementation using the latest Rust edition
  • Incredibly tiny β€” 108 KB stripped, ~54 KB with UPX compression
  • True #[no_std] β€” no standard library dependency, only libc and alloc
  • Android-native β€” first-class Android/Bionic support, works on Android 5.0+
  • Embedded-ready β€” works on systems without full std support
  • Cross-platform β€” builds for Linux (glibc/musl), Android, x86_64, ARM64, ARM32
  • POSIX.1-2017 compliant β€” core utilities follow the POSIX standard

πŸ“Š Binary Size Comparison

Binary Size UPX Size Applets Size/Applet
Armybox 108 KB ~54 KB 293 ~380 bytes
Toybox ~500 KB ~200 KB 238 ~2.1 KB
BusyBox 2.4 MB ~1 MB 274 ~9 KB

Armybox is 24x more efficient per applet than BusyBox and 5.5x more efficient than Toybox!

πŸš€ Quick Start

# Clone and build
git clone https://github.com/pegasusheavy/armybox
cd armybox
cargo build --release

# Install symlinks
sudo ./target/release/armybox --install /usr/local/bin

# Compress with UPX (optional)
upx --best target/release/armybox

πŸ“š Applet Categories (293 total)

File Operations (45+)

basename, cat, cd, chattr, chgrp, chmod, chown, cp, dd, dirname, fallocate, file, find, fstype, install, link, ln, ls, lsattr, makedevs, mkdir, mkfifo, mknod, mktemp, mv, patch, pwd, readlink, realpath, rm, rmdir, setfattr, shred, split, stat, sync, touch, truncate, unlink, xargs

Text Processing (35+)

awk, base32, base64, comm, cut, dos2unix, echo, egrep, expand, fgrep, fmt, fold, grep, head, iconv, nl, paste, printf, rev, sed, seq, sort, strings, tac, tail, tee, tr, tsort, unexpand, uniq, unix2dos, wc, yes

System Utilities (60+)

acpi, arch, blkdiscard, blkid, blockdev, cal, chroot, chrt, chvt, date, deallocvt, devmem, df, dmesg, dnsdomainname, du, env, fgconsole, flock, free, freeramdisk, fsfreeze, fsync, getconf, getopt, groups, halt, hostid, hostname, hwclock, id, insmod, ionice, iorenice, iotop, linux32, logger, logname, losetup, lsmod, lspci, lsusb, modinfo, modprobe, mount, mountpoint, nice, nohup, nproc, openvt, partprobe, pivot_root, poweroff, printenv, reboot, readahead, renice, rfkill, rmmod, rtcwake, swapoff, swapon, sysctl, taskset, timeout, top, tty, umount, uname, uptime, users, vmstat, w, watch, who, whoami

Process Management (15+)

kill, killall, killall5, pgrep, pidof, pkill, pmap, prlimit, ps, pwdx, renice, setsid, time

Shell (3)

sh, ash, dash β€” full POSIX-compliant shell

Vi Editor (2)

vi, view β€” modal editor with normal, insert, and command-line modes

Terminal Multiplexer (2)

screen, tmux β€” terminal session management

Init System (6)

init, getty, linuxrc, runlevel, sulogin, telinit

Networking (35+)

arp, arping, brctl, ftpget, ftpput, host, httpd, ifconfig, ifdown, ifup, ip, ipaddr, ipcalc, iplink, ipneigh, iproute, iprule, nameif, nbd-client, nbd-server, nc, netcat, netstat, nslookup, ping, ping6, route, slattach, sntp, ss, telnet, tftp, traceroute, traceroute6, tunctl, wget

Archive & Compression (15)

bunzip2, bzcat, bzip2, compress, cpio, gunzip, gzip, tar, uncompress, unxz, unzip, xz, xzcat, zcat

Checksums & Crypto (10)

cksum, crc32, md5sum, sha1sum, sha224sum, sha256sum, sha384sum, sha3sum, sha512sum

Hardware & GPIO (15+)

devmem, gpiodetect, gpiofind, gpioget, gpioinfo, gpioset, i2cdetect, i2cdump, i2cget, i2cset, i2ctransfer, lspci, lsusb

Miscellaneous (25+)

[, ascii, clear, cmp, count, diff, expr, factor, false, help, hexdump, hexedit, mcookie, memeater, mesg, microcom, mix, mkpasswd, mkswap, nologin, nsenter, oneit, pwgen, readelf, reset, shuf, sleep, switch_root, test, toybox, true, ts, uclampset, ulimit, unicode, unshare, usleep, uudecode, uuencode, uuidgen, watchdog

πŸ“± Android Support

Armybox has native Android support with Bionic libc compatibility.

# Install Android targets
rustup target add aarch64-linux-android    # ARM64 (most modern devices)
rustup target add armv7-linux-androideabi  # ARMv7 (older 32-bit)
rustup target add x86_64-linux-android     # x86_64 (emulator/Chromebook)

# Set up Android NDK (required)
export ANDROID_NDK_HOME=/path/to/android-ndk
export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin

# Build for Android ARM64
cargo build --release --target aarch64-linux-android

# Deploy via ADB
adb push target/aarch64-linux-android/release/armybox /data/local/tmp/
adb shell chmod +x /data/local/tmp/armybox
adb shell /data/local/tmp/armybox --list

πŸ“¦ Usage

Direct Invocation

./armybox ls -la
./armybox cat file.txt
./armybox echo "Hello, World!"
./armybox sh  # Start POSIX shell
./armybox vi file.txt  # Edit with vi
./armybox screen  # Terminal multiplexer

List Available Applets

./armybox --list

Via Symlinks

After installing symlinks:

ls -la
cat file.txt
echo "Hello!"

πŸ“š Library Usage

Armybox is a #[no_std] library that can be used in embedded environments.

Cargo.toml

[dependencies]
armybox = { version = "0.3", default-features = false, features = ["alloc"] }

Features

Feature Description Default
alloc Heap allocation (Vec, String) βœ…
std Standard library support ❌
apk APK package manager support ❌

Example

#![no_std]
extern crate alloc;

use armybox::applets;

// Find and run an applet
if let Some(func) = applets::find_applet(b"echo") {
    let args = [b"echo\0".as_ptr(), b"hello\0".as_ptr()];
    func(2, args.as_ptr());
}

πŸ—οΈ Architecture

src/
β”œβ”€β”€ lib.rs          # Library entry (no_std compatible)
β”œβ”€β”€ main.rs         # Binary entry (no_std, no_main)
β”œβ”€β”€ io.rs           # Raw I/O via libc
β”œβ”€β”€ sys.rs          # System utilities
└── applets/
    β”œβ”€β”€ mod.rs      # Applet registry (293 applets)
    β”œβ”€β”€ file.rs     # File operations
    β”œβ”€β”€ text.rs     # Text processing
    β”œβ”€β”€ system.rs   # System utilities
    β”œβ”€β”€ misc.rs     # Miscellaneous
    β”œβ”€β”€ network.rs  # Networking
    β”œβ”€β”€ archive.rs  # Archive/compression
    β”œβ”€β”€ init.rs     # Init system
    β”œβ”€β”€ shell.rs    # POSIX shell
    β”œβ”€β”€ vi.rs       # Vi editor
    └── screen.rs   # Terminal multiplexer

🐳 Docker

Use armybox as a minimal base for containers. Perfect for FROM scratch images.

FROM scratch
COPY target/release/armybox /bin/armybox
RUN ["/bin/armybox", "--install", "/bin"]
ENTRYPOINT ["/bin/sh"]

Build: docker build -t myapp . β†’ ~100KB image!

πŸ” How It Works

Armybox is built entirely with #[no_std]:

  1. No Rust Standard Library β€” Only uses core and alloc
  2. Direct libc Calls β€” All I/O goes through raw libc::* functions
  3. Custom Allocator β€” Uses libc::malloc/free for heap allocation
  4. Custom Panic Handler β€” Minimal panic handling without unwinding
  5. No Main Runtime β€” Uses #[no_main] with raw C entry point

This results in an incredibly small binary that's perfect for:

  • Embedded systems
  • Containers (FROM scratch)
  • Rescue environments
  • Space-constrained systems
  • Android devices

πŸ“‹ Comparison

Feature Armybox Toybox BusyBox
Language Rust C C
Memory Safety βœ… Compile-time ❌ Manual ❌ Manual
Binary Size 108 KB ~500 KB 2.4 MB
Per-Applet Size ~380 bytes ~2.1 KB ~9 KB
#[no_std] βœ… N/A N/A
Applet Count 293 238 274
Toybox Compatible βœ… 100% N/A Partial
POSIX Shell βœ… βœ… βœ…
Vi Editor βœ… βœ… βœ…
Init System βœ… Partial βœ…
Terminal Multiplexer βœ… ❌ ❌
License MIT/Apache-2.0 0BSD GPL v2

🀝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

πŸ“„ License

Licensed under either of:

at your option.

πŸ™ Acknowledgments

  • Toybox β€” BSD-licensed Unix utilities
  • BusyBox β€” The original multi-call binary inspiration
  • libc β€” Rust FFI bindings to platform libraries

Made with ❀️ by Pegasus Heavy Industries

About

A #[no_std] BusyBox/Toybox clone in Rust - 291 applets, 108KB binary, 100% Toybox compatible

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors