When you connect to an Oniro or OpenHarmony (OHOS) device via hdc shell
, you have a very minimal system. This is intentional. Oniro/OHOS is a very lightweight operating system for devices such as phone/tablets, single board computers and micro controllers.
However, for developers and device engineers, it is sometimes useful to have more capabilities available on a device for troubleshooting or testing lower-level code on actual hardware.
What’s included in the OS?
By default Oniro/OHOS does come with quite a good set of utilities via toybox.
Toybox was created by one of the BusyBox team as a way to augment Android’s command line toolset.
There is certainly a large overlap between the BusyBox utilities and those already available with Oniro/OHOS via Toybox.
However, if you are looking to do things like edit files or run code directly on an Oniro/OHOS device, BusyBox might be more useful.
About BusyBox
If you haven’t come across BusyBox, it’s a bundle of familiar Unix/Linux command line tools that’s ideal for using on systems that don’t come with many built-in capabilities.
A list of the tools that are included in BusyBox can be found below. For me, the utilities that were missing from a standard Oniro/OHOS build have been unzip
and vi.
Just one example where I found this useful was when testing some C++ components directly on a device.
Let’s get into the steps to put BusyBox onto a device.
Setup Steps
Firstly, download Busybox for your device’s architecture:
For the HopeRun dayu200 board, I downloaded the arm64_v8a version.
You can then use hdc to put BusyBox on your device.
#Get the IDs of your connected devices
hdc list targets
#Send the BusyBox tarball to your device.
hdc -t <device-id> file send <file-path>\busybox.tar.gz /data
#Open an interactive shell on your device
hdc -t <device-id> shell
//// Inside the device shell
#mount the root directory to be read/write
mount -o remount,rw /
#Unpack the busybox tarball to /data/busybox
cd /data
mkdir -p busybox
tar -xvf busybox.tar.gz -C busybox
#Finally put a symbolic link in the bin path
ln -s /data/busybox/bin/busybox /bin/busybox
You can test that everything is working correctly by trying a few commands.
#Simple test
busybox echo "hello Oniro"
#Open vi to edit a file
busybox vi
#Check the device's network interfaces
busybox ifconfig
#Show the device's mounted filesystems
busybox df
Simple HTTP Server with BusyBox
For fun, let’s use BusyBox to turn our device into a web server.
#Create a directory to store our html files
mkdir -p /data/d/oniro-html
#Fetch an image to show in an HTML page
#Note: the busybox wget version doesn't support https :(
busybox wget -P /data/d/oniro-html http://storage.googleapis.com/ohos-demo-file-http/oniro-architecture.jpg
#Let's write a simple html file
busybox vi /data/d/oniro-http/index.html
#Finally, let's run a simple HTTP service
busybox httpd -p 8080 /data/d/oniro-http
#To see our page, we need to know the device's IP address
busybox ifconfig
We can now open the page in the browser. For my device I went to http://192.168.68.55:8080.
To stop the HTTP server on the device, do the following.
#Get the process ID for httpd
busybox ps | grep httpd
#Ruthlessly kill it
busybox kill <PID>
Summary
Toybox is pretty good and will probably be enough for inspecting what’s happening on your devices.
BusyBox adds more capabilities and can be very useful when working with development devices.
The steps to add BusyBox are pretty easy when there is a tool you need.
References
Appendix: BusyBox Utilities
For a full list and more useful information about the commands available with BusyBox, read this.
1. File and Directory Management
ls
,cp
,mv
,rm
,mkdir
,rmdir
– Manage files and directories.touch
– Create or update the timestamp of files.find
– Locate files based on criteria like name, size, etc.du
,df
– Check disk usage and filesystem free space.tar
,gzip
,bzip2
– Work with compressed archives.
2. File Viewing and Text Processing
cat
,more
,less
,head
,tail
– Display file contents.grep
– Search text in files.sed
,awk
– Perform basic text processing.wc
– Count lines, words, and characters in files.cut
,sort
,uniq
,tr
– Manipulate and transform text.
3. System Information
uname
– Show system information like kernel name and version.df
,du
– Check disk usage.free
– Display memory usage.uptime
– Check how long the system has been running.top
– Monitor processes and system resources (if included).ps
– View running processes.dmesg
– Display kernel messages.
4. Network Utilities
ifconfig
,ip
– Configure network interfaces.ping
– Check network connectivity.telnet
,nc
(netcat) – Connect to remote servers.wget
– Download files over HTTP/FTP.nslookup
,route
– Check DNS info and routing tables.
5. User and Permission Management
adduser
,deluser
,passwd
– Manage users and passwords.chmod
,chown
,chgrp
– Set file permissions and ownership.id
– Display user identity and group memberships.
6. Device and Process Management
mount
,umount
– Mount and unmount filesystems.mknod
– Create block or character device files.kill
,killall
– Terminate processes by PID or name.reboot
,shutdown
– Reboot or shut down the system.
7. Package Management and Initialization (System Setup)
init
,shutdown
,halt
– Basic system initialization and shutdown.crond
– Run scheduled tasks (likecron
).syslogd
,klogd
– Log system events and kernel messages.
8. Shell and Scripting
ash
– The lightweight shell included with BusyBox, compatible with most basic shell scripts.Environment management commands like
export
,set
, andunset
.Basic scripting tools such as
test
,expr
,echo
,read
,sleep
, and conditional logic withif
,while
,for
, etc.
9. Compression and Archiving
tar
,gzip
,bzip2
,xz
– Manage compressed files and archives.unzip
– Extract.zip
files.
10. Date and Time Management
date
– Display or set the system date and time.hwclock
– Access and set the hardware clock (if supported).sleep
,time
– Pause or time the duration of commands.
11. Development and Debugging Tools
hexdump
– Display file contents in hexadecimal format.strings
– Extract printable strings from binary files.od
– Display file contents in octal, hexadecimal, or other formats.
acpid, addgroup, adduser, adjtimex, ar, arp, arping, ash, awk, basename, beep, blkid, brctl, bunzip2, bzcat, bzip2, cal, cat, catv, chat, chattr, chgrp, chmod, chown, chpasswd, chpst, chroot, chrt, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, dpkg, du, dumpkmap, dumpleases, echo, ed, egrep, eject, env, envdir, envuidgid, expand, expr, fakeidentd, false, fbset, fbsplash, fdflush, fdformat, fdisk, fgrep, find, findfs, flash_lock, flash_unlock, fold, free, freeramdisk, fsck, fsck.minix, fsync, ftpd, ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip, hd, hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock, id, ifconfig, ifdown, ifenslave, ifplugd, ifup, inetd, init, inotifyd, insmod, install, ionice, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5, klogd, last, length, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger, login, logname, logread, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lzmacat, lzop, lzopcat, makemime, man, md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mkfifo, mkfs.minix, mkfs.vfat, mknod, mkpasswd, mkswap, mktemp, modprobe, more, mount, mountpoint, mt, mv, nameif, nc, netstat, nice, nmeter, nohup, nslookup, od, openvt, passwd, patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root, pkill, popmaildir, printenv, printf, ps, pscan, pwd, raidautorun, rdate, rdev, readlink, readprofile, realpath, reformime, renice, reset, resize, rm, rmdir, rmmod, route, rpm,rpm2cpio, rtcwake, run-parts, runlevel, runsv, runsvdir, rx, script, scriptreplay, sed, sendmail, seq, setarch, setconsole, setfont, setkeycodes, setlogcons, setsid, setuidgid, sh, sha1sum, sha256sum, sha512sum, showkey, slattach, sleep, softlimit, sort, split, start-stop-daemon, stat, strings, stty, su, sulogin, sum, sv, svlogd, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac, tail, tar, taskset, tcpsvd, tee, telnet, telnetd, test, tftp, tftpd,time, timeout, top, touch, tr, traceroute, true, tty, ttysize, udhcpc, udhcpd, udpsvd, umount, uname, uncompress, unexpand, uniq, unix2dos, unlzma, unlzop, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, volname, watch, watchdog, wc, wget, which, who, whoami, xargs, yes, zcat, zcip