toybox

Note:

Currently in the beta phase.

toybox is a lightweight collection of Linux command-line utilities that combines commonly used Linux commands into a single executable.

Prerequisites

Usage Method 1

  • Connect the device normally
  • Use hdc shell to enter command-line execution mode

Usage Method 2

  • Run within the application sandbox

Command Line Instructions

toybox can be executed in two ways:

  • toybox [command] [arguments...]
  • Direct execution: [command] [arguments...]

Where [command] can be replaced with any command supported by toybox (queryable by running toybox without parameters).
[arguments...] represents the parameters required by [command].

Help Command

Format: toybox [--long | --help | --version | [command] [arguments...]]

Option Parameters Description
--help NA Display command help.
--long NA Display paths of all supported commands.
--version NA Display version number.
NA NA Display all commands supported by [command].
[command] [arguments] Execute specific command. Most commands also support --help and --version parameters.

Format: help [-ah] [command]

Parameter Description
command Display help for command. [command] can be replaced with any command supported by toybox.
Option Description
-a Display help for all commands.

Mathematical & Computer Fundamentals

Command Description
ascii Display ASCII encoding table.
Usage: ascii
factor Factorize numbers.
Usage: factor NUMBER...
mcookie Generate 128-bit strong random number.
Usage: mcookie [-vV]
mkpasswd Encrypt passwords.
Usage: mkpasswd [-P FD] [-m TYPE] [-S SALT] [PASSWORD] [SALT]
uuidgen Create and print new RFC4122 random UUID.
Usage: uuidgen

Terminal Operations

Command Description
chvt Switch to virtual terminal N.
Usage: chvt N
chroot Run command with specified root directory.
Usage: chroot NEWROOT [COMMAND [ARG...]]
clear Clear terminal.
Usage: clear
nohup Run command immune to hangups.
Usage: nohup COMMAND [ARG...]
tty Display terminal name connected to stdin.
Usage: tty [-s]
reset Reset terminal.
Usage: reset
microcom Simple serial terminal.
Usage: microcom [-s SPEED] [-X] DEVICE

Shell Logic Commands

Command Description
false Return non-zero value.
Usage: false
sh Shell command interpreter.
test Evaluate expression returning true/false. Returns false if no arguments.
Usage: test [-bcdefghLPrSsuwx PATH] [-nz STRING] [-t FD] [X ?? Y]
true Return zero.
Usage: true
yes Repeatedly output line until killed. Outputs "y" if no arguments.
Usage: yes [args...]

System Operations

Command Description
acpi Query power/temperature status.
Usage: acpi [-abctV]
arch Print system architecture.
Usage: arch
dmesg Display/control kernel ring buffer.
Usage: dmesg [-Cc] [-r | -t | -T] [-n LEVEL] [-s SIZE] [-w]
dnsdomainname Display system name (same as hostname -d).
Usage: dnsdomainname
getconf Get system configuration values (some require path parameter).
Usage: getconf -a [PATH] | -l | NAME [PATH]
env Set environment for command invocation or list environment variables.
Usage: env [-i] [-u NAME] [NAME=VALUE...] [COMMAND [ARG...]]
hostname Get/set hostname.
Usage: hostname [-bdsf] [-F FILENAME] [newname]
insmod Load kernel module.
Usage: insmod MODULE [MODULE_OPTIONS]
logger Log system messages.
Usage: logger [-s] [-t TAG] [-p [FACILITY.]PRIORITY] [message...]
lsmod Show loaded modules with sizes/dependencies.
Usage: lsmod
mix Display/set OSS mixer channels.
Usage: mix [-d DEV] [-c CHANNEL] [-l VOL] [-r RIGHT]
modinfo Show kernel module information.
Usage: modinfo [-0] [-b basedir] [-k kernel] [-F field] [module | file...]
nproc Print processor count.
Usage: nproc [--all]
oneit Simple init program.
Usage: oneit [-p] [-c /dev/tty0] command [...]
partprobe Inform kernel of partition table changes.
Usage: partprobe DEVICE...
pivot_root Change root directory.
Usage: pivot_root OLD NEW
printenv Print environment variables.
Usage: printenv [-0] [env\_var...]
reboot/halt/poweroff Reboot/stop/power off.
Usage: reboot/halt/poweroff [-fn]
rfkill Enable/disable wireless devices.
Usage: rfkill COMMAND [DEVICE]
rmmod Unload kernel module.
Usage: rmmod [-wf] [MODULE]
sendevent Send Linux input event.
Usage: sendevent DEVICE TYPE CODE VALUE
swapoff Disable swap space.
Usage: swapoff swapregion
swapon Enable swapping on specified device/file.
Usage: swapon [-d] [-p priority] filename
switch_root Switch root directory and execute new INIT.
Usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT...
uname Print system information.
Usage: uname [-asnrvm]
vmstat Print virtual memory statistics.
Usage: vmstat [-n] [DELAY [COUNT]]

Time & Date

Command Description
cal Print calendar.
Usage: cal [[month] year]
date Set/get current date/time.
Usage: date [-u] [-r FILE] [-d DATE] [+DISPLAY\_FORMAT] [SET]
hwclock Get/set hardware clock.
Usage: hwclock [-rswtluf]
sleep Wait for specified duration before exiting. Can be fractional. Optional suffixes: "m" (minutes), "h" (hours), "d" (days), or "s" (seconds, default).
Usage: sleep DURATION
time Run command line and report real/user/system time in seconds.
Usage: time [-pv] COMMAND [ARGS...]
uptime Display current time, system uptime, user count, and load averages.
Usage: uptime [-ps]
usleep Wait for specified microseconds before exiting.
Usage: usleep MICROSECONDS

User Operations

Command Description
groups Print user's groups.
Usage: groups [user]
id Print user/group IDs.
Usage: id [-nGgru] [USER...]
login User login.
Usage: login [-p] [-h host] [-f USERNAME] [USERNAME]
logname/whoami Print current username.
Usage: logname/whoami
passwd Update user authentication token.
Usage: passwd [-a ALGO] [-dlu] [USER]
who Print logged-in users.
Usage: who
w Show logged-in users and login times.
Usage: w

Process Operations

Command Description
chrt Get/set process scheduling policy/priority.
Usage: chrt [-Rmofrbi] {-p PID [PRIORITY] | [PRIORITY COMMAND...]}
iorenice Show/modify process I/O priority.
Usage: iorenice PID [CLASS] [PRIORITY]
iotop Sort processes by I/O.
Usage: iotop [-AaKObq] [-n NUMBER] [-d SECONDS] [-p PID,] [-u USER,]
ionice Show/modify process I/O scheduling priority.
Usage: ionice [-t] [-c CLASS] [-n LEVEL] [COMMAND...|-p PID]
kill Send signal to process.
Usage: kill [-l [SIGNAL] | -s SIGNAL | -SIGNAL] pid...
killall Send signal to all processes with given name (default: SIGTERM).
Usage: killall [-l] [-iqv] [-SIGNAL | -s SIGNAL] PROCESS\_NAME...
killall5 Send signal to all processes outside current session.
Usage: killall5 [-l [SIGNAL]] [-SIGNAL | -s SIGNAL] [-o PID]...
pidof Print PIDs of processes with given name.
Usage: pidof [-s] [-o omitpid[,omitpid...]] [NAME...]
pkill Kill processes by name.
Usage: pkill [-fnovx] [-SIGNAL | -l SIGNAL] [PATTERN] [-G GID,] [-g PGRP,] [-P PPID,] [-s SID,] [-t TERM,] [-U UID,] [-u EUID,]
pmap Show process memory map.
Usage: pmap [-xq] [pids...]
ps Show process information.
Usage: ps [-AadefLlnwZ] [-gG GROUP,] [-k FIELD,] [-o FIELD,] [-p PID,] [-t TTY,] [-uU USER,]
pwdx Print process working directory.
Usage: pwdx PID...
renice Adjust process/group/user priority.
Usage: renice [-gpu] -n increment ID ...
setsid Run command in new session.
Usage: setsid [-t] command [args...]
taskset Start task running only on specified processors.
Usage: taskset [-ap] [mask] [PID | cmd [args...]]
timeout Execute command with timeout.
Usage: timeout [-k DURATION] [-s SIGNAL] DURATION COMMAND...
top Show real-time process information.
Usage: top [-Hhbq] [-k FIELD,] [-o FIELD,] [-s SORT] [-n NUMBER] [-m LINES] [-d SECONDS] [-p PID,] [-u USER,]
nice Run command with specified priority.
Usage: nice [-n PRIORITY] COMMAND [ARG...]
nsenter Run command in specified namespace.
Usage: nsenter [-t pid] [-F] [-i] [-m] [-n] [-p] [-u] [-U] COMMAND...
ulimit/prlimit Show/set process resource limits.
Usage: ulimit/prlimit [-P PID] [-SHRacdefilmnpqrstuv] [LIMIT]
unshare Create new namespace for process.
Usage: unshare [-imnpuUr] COMMAND...
watch Run command repeatedly, showing output.
Usage: watch [-teb] [-n SEC] PROG ARGS
xargs Run command line with arguments from stdin.
Usage: xargs [-0prt] [-s NUM] [-n NUM] [-E STR] COMMAND...

Device Node Operations

Command Description
blkid Print filesystem type/label/UUID.
Usage: blkid [-s TAG] [-UL] DEV...
blockdev Call ioctl on block devices.
Usage: blockdev --OPTION... BLOCKDEV...
devmem Read/write physical address via /dev/mem.
Usage: devmem ADDR [WIDTH [DATA]]
df Show disk space usage.
Usage: df [-HPkhi] [-t type] [FILESYSTEM ...]
du Show disk usage by files/directories.
Usage: du [-d N] [-askxHLlmc] [file...]
eject Eject device (default: /dev/cdrom).
Usage: eject [-stT] [DEVICE]
free Show memory/swap usage.
Usage: free [-bkmgt]
freeramdisk Free all memory of specified ramdisk.
Usage: freeramdisk [RAM device]
fsfreeze Freeze/unfreeze filesystem.
Usage: fsfreeze {-f | -u} MOUNTPOINT
fstype Print filesystem type.
Usage: fstype DEV...
fsync Sync file state with storage.
Usage: fsync [-d] [FILE...]
i2cdetect Detect i2c devices.
Usage:
i2cdetect [-ary] BUS [FIRST LAST]
i2cdetect -F BUS
i2cdetect -l
i2cdump Print all i2c registers.
Usage: i2cdump [-fy] BUS CHIP
i2cget Read i2c register.
Usage: i2cget [-fy] BUS CHIP ADDR
i2cset Write i2c register.
Usage: i2cset [-fy] BUS CHIP ADDR VALUE... MODE
losetup Setup loop devices.
Usage: losetup [-cdrs] [-o OFFSET] [-S SIZE] {-d DEVICE... | -j FILE | -af | {DEVICE FILE}}
lspci Show PCI device info.
Usage: lspci [-ekmn] [-i FILE ]
lsusb Show USB device info.
Usage: lsusb
makedevs Create special files (block/char devices etc).
Usage: makedevs [-d device_table] rootdir
mount Mount filesystem or show mounts.
Usage: mount [-afFrsvw] [-t TYPE] [-o OPTION,] [[DEVICE] DIR]
mountpoint Check if directory/device is mountpoint.
Usage:
mountpoint [-qd] DIR
mountpoint [-qx] DEVICE
sync Write cached data to disk.
Usage: sync
sysctl Read/write system control data.
Usage: sysctl [-aAeNnqw] [-p [FILE] | KEY[=VALUE]...]
tunctl Create/delete tun/tap virtual ethernet devices.
Usage: tunctl [-dtT] [-u USER] NAME
vconfig Create/delete virtual ethernet devices.
Usage: vconfig COMMAND [OPTIONS]
umount Unmount filesystem.
Usage: umount [-a [-t TYPE[,TYPE...]]] [-vrfD] [DIR...]

Network Operations

Command Description
ftpget/ftpput Interact with FTP server (read/write/list files). ftpget includes -g option. ftpput includes -s option.
Usage: ftpget/ftpput [-cvgslLmMdD] [-p PORT] [-P PASSWORD] [-u USER] HOST [LOCAL] REMOTE
ifconfig Configure network interfaces.
Usage: ifconfig [-aS] [INTERFACE [ACTION...]]
nbd-client Create NBD client.
Usage: nbd-client [-ns] HOST PORT DEVICE
netstat Show network info.
Usage: netstat [-pWrxwutneal]
ping/ping6 Test network connectivity. ping6 includes -6 option.
Usage: `ping/ping