openharmony 鸿蒙 toybox

2025-06-12 浏览 (1)

Toybox

Toybox is a lightweight collection of Linux command line utilities. It combines many common Linux command line utilities into a single executable file.

Prerequisites

Usage 1

  • Connect the device properly.
  • Run the hdc shell command to enter the command line execution mode.

Usage 2

  • Enter the application sandbox.

Command Description

Toybox can be executed in either of the following ways:

  • Run the toybox [command] [arguments...] command.

  • Run the [command] [arguments...] command.

[command] can be any command supported by toybox. You can run the toybox command to query the supported commands. [arguments...] are the parameters required by a [command].

Help Command

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

OptionParameterDescription
--helpNADisplays the command help.
--longNADisplays all supported commands along with their respective installation path.
--versionNADisplays the version number.
NANADisplays all supported commands.
[command][arguments]Runs a specific command. Most commands also support the --help and --version parameters.

Format: help [-ah] [command]

ParameterDescription
commandDisplays the command help. [command] can be any command supported by toybox.
OptionDescription
-aDisplays the help information about all commands.
-hDisplays the help information in HTML format.

Mathematics and Basic Computer Functions

CommandDescription
asciiDisplays the ASCII table.
usage: ascii
factorFactors an integer.
usage: factor NUMBER...
mcookieGenerates a 128-bit strong random number.
usage: mcookie [-vV]
mkpasswdEncrypts a password.
usage: mkpasswd [-P FD] [-m TYPE] [-S SALT] [PASSWORD] [SALT]
uuidgenCreates and prints a new RFC4122 random UUID.
usage: uuidgen

Device Operations

CommandDescription
chvtSwitches to virtual device N.
usage: chvt N
chrootRuns a command in the specified root directory.
usage: chroot NEWROOT [COMMAND [ARG...]]
clearClears the terminal.
usage: clear
nohupRuns a command independent of the terminal.
usage: nohup COMMAND [ARG...]
ttyDisplays the name of the device connected to the standard input device.
usage: tty [-s]
resetResets the terminal.
usage: reset
microcomRuns a simple serial console.
usage: microcom [-s SPEED] [-X] DEVICE

sh Logical Commands

CommandDescription
falseReturns a non-zero value.
usage: false
shshell command interpreter.
testPerforms a test and returns true or false. If no parameter is carried, false is returned.
usage: test [-bcdefghLPrSsuwx PATH] [-nz STRING] [-t FD] [X ?? Y]
trueReturns zero.
usage: true
yesOutputs lines repeatedly until it is killed. If no parameter is carried, y is returned.
usage: yes [args...]

System Operations

CommandDescription
acpiObtains the power supply and temperature status.
usage: acpi [-abctV]
archPrints the system name.
usage: arch
dmesgDisplays or controls the kernel ring buffer.
usage: dmesg [-Cc] [-r |-t |-T] [-n LEVEL] [-s SIZE] [-w]
dnsdomainnameDisplays the system name, which is the same as the value of hostname -d.
usage: dnsdomainname
getconfObtains system configuration values. Some values require the path parameter.
usage: getconf -a [PATH] |-l |NAME [PATH]
envSets the environment for command execution or lists environment variables.
usage: env [-i] [-u NAME] [NAME=VALUE...] [COMMAND [ARG...]]
hostnameObtains the current host name.
usage: hostname [-bdsf] [-F FILENAME] [newname]
insmodLoads a kernel module.
usage: insmod MODULE [MODULE_OPTIONS]
loggerRecords system logs.
usage: logger [-s] [-t TAG] [-p [FACILITY.]PRIORITY] [message...]
lsmodDisplays the loaded modules, their sizes, and their dependencies.
usage: lsmod
mixDisplays the OSS audio channel or sets the volume.
usage: mix [-d DEV] [-c CHANNEL] [-l VOL] [-r RIGHT]
modinfoDisplays the kernel module information.
usage: modinfo [-0] [-b basedir] [-k kernel] [-F field] [module |file...]
nprocPrints the number of processors.
usage: nproc [--all]
oneitRuns a simple initialization program.
usage: oneit [-p] [-c /dev/tty0] command [...]
partprobeNotifies the kernel that the partitioned table has changed.
usage: partprobe DEVICE...
pivot_rootModifies the root directory.
usage: pivot_root OLD NEW
printenvPrints environment variables.
usage: printenv [-0] [env_var...]
reboot/halt/poweroffReboots, halts, or powers off a system.
usage: reboot/halt/poweroff [-fn]
rfkillEnables or disables a wireless device.
usage: rfkill COMMAND [DEVICE]
rmmodUninstalls a kernel module.
usage: rmmod [-wf] [MODULE]
sendeventSends a Linux input event.
usage: sendevent DEVICE TYPE CODE VALUE
swapoffDeactivates a swap space.
usage: swapoff swapregion
swaponActivates a swap partition in a specified device or file.
usage: swapon [-d] [-p priority] filename
switch_rootSwitches to the root directory and runs a new init program.
usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT...
unamePrints system information.
usage: uname [-asnrvm]
vmstatPrints virtual memory information.
usage: vmstat [-n] [DELAY [COUNT]]

Time and Date

CommandDescription
calPrints a calendar.
usage: cal [[month] year]
dateSets or obtains the current date and time.
usage: date [-u] [-r FILE] [-d DATE] [+DISPLAY_FORMAT] [SET]
hwclockObtains or sets the hardware clock.
usage: hwclock [-rswtluf]
sleepWaits before exiting. The value can be a decimal. The optional suffix can be "m" (minute), "h" (hour), "d" (day), or "s" (second, default value).
usage: sleep DURATION
timeRuns the command line and reports the real time, user time, and system time (in seconds). The real time is the wall clock time, the user time is the actual CPU time spend in user-mode, and the system time is the actual CPU time sped in the kernel.
usage: time [-pv] COMMAND [ARGS...]
uptimeDisplays the current time, how long the system has been running, the number of users, and the average system load in the past 1, 5, and 15 minutes.
usage: uptime [-ps]
usleepWaits for the configured time before exiting, in microseconds.
usage: usleep MICROSECONDS

Login User Operations

CommandDescription
groupsPrints the group to which the user belongs.
usage: groups [user]
idPrints the user and group ID.
usage: id [-nGgru] [USER...]
loginLogs in as a user.
usage: login [-p] [-h host] [-f USERNAME] [USERNAME]
logname/whoamiPrints the current user name.
usage: logname/whoami
passwdUpdates the authentication token of a user.
usage: passwd [-a ALGO] [-dlu] [USER]
whoPrints information about logged in users.
usage: who
wDisplays the user login information and login time.
usage: w

Process Operations

CommandDescription
chrtObtains or sets the scheduling policy and priority of a process.
usage: chrt [-Rmofrbi] {-p PID [PRIORITY] |[PRIORITY COMMAND...]}
ioreniceDisplays or modifies the I/O priority of a process.
usage: iorenice PID [CLASS] [PRIORITY]
iotopSorts processes based on the I/O priority.
usage: iotop [-AaKObq] [-n NUMBER] [-d SECONDS] [-p PID,] [-u USER,]
ioniceDisplays or modifies the I/O scheduling priority of a process.
usage: ionice [-t] [-c CLASS] [-n LEVEL] [COMMAND...|-p PID]
killSends a signal to a process.
usage: kill [-l [SIGNAL] |-s SIGNAL |-SIGNAL] pid...
killallSends a signal (SIGTERM by default) to all processes with the given name.
usage: killall [-l] [-iqv] [-SIGNAL |-s SIGNAL] PROCESS_NAME...
killall5Sends signals to all processes except the current session.
usage: killall5 [-l [SIGNAL]] [-SIGNAL |-s SIGNAL] [-o PID]...
pidofPrints the PIDs of all processes with the given name.
usage: pidof [-s] [-o omitpid[,omitpid...]] [NAME...]
pkillKills a process by process name.
usage: pkill [-fnovx] [-SIGNAL |-l SIGNAL] [PATTERN] [-G GID,] [-g PGRP,] [-P PPID,] [-s SID,] [-t TERM,] [-U UID,] [-u EUID,]
pmapObtains the memory mapping of a process.
usage: pmap [-xq] [pids...]
psDisplays information of a process.
usage: ps [-AadefLlnwZ] [-gG GROUP,] [-k FIELD,] [-o FIELD,] [-p PID,] [-t TTY,] [-uU USER,]
pwdxPrints the working directory of a process.
usage: pwdx PID...
reniceAdjusts the priority of processes, process groups, and user-level processes.
usage: renice [-gpu] -n increment ID ...
setsidRuns a command in a new session.
usage: setsid [-t] command [args...]
tasksetStarts a task that runs only on a specified processor, or modifies the processor affinity of an existing process.
usage: taskset [-ap] [mask] [PID |cmd [args...]]
timeoutRuns a command in a child process and if the command execution is not finished within a time limit, sends a signal. The value of DURATION can be a decimal. The optional suffix can be "m" (minute), "h" (hour), "d" (day), or "s" (second, default value).
usage: timeout [-k DURATION] [-s SIGNAL] DURATION COMMAND...
topDisplays process information in real time.
usage: top [-Hhbq] [-k FIELD,] [-o FIELD,] [-s SORT] [-n NUMBER] [-m LINES] [-d SECONDS] [-p PID,] [-u USER,]
niceRuns a command with a specified priority.
usage: nice [-n PRIORITY] COMMAND [ARG...]
nsenterRuns a command in a specific namespace.
usage: nsenter [-t pid] [-F] [-i] [-m] [-n] [-p] [-u] [-U] COMMAND...
ulimit/prlimitDisplays or sets the resource limit of a process.
usage: ulimit/prlimit [-P PID] [-SHRacdefilmnpqrstuv] [LIMIT]
unshareCreates a namespace for a process. Some attributes are not shared with the parent process.
usage: unshare [-imnpuUr] COMMAND...
watchRuns the specified commands at a given interval (specified by -n, in seconds) and displays the execution result. You can press q to exit the command execution.
usage: watch [-teb] [-n SEC] PROG ARGS
xargsRuns the command line one or more times, carrying parameters from the standard input device.
usage: xargs [-0prt] [-s NUM] [-n NUM] [-E STR] COMMAND...

Device Node Operations

CommandDescription
blkidPrints information of the file system, such as type, tag, and UUID.
usage: blkid [-s TAG] [-UL] DEV...
blockdevInvokes ioctl for the block device in each command.
usage: blockdev --OPTION... BLOCKDEV...
devmemReads and writes the physical address using /dev/mem.
usage: devmem ADDR [WIDTH [DATA]]
dfDisplays the total, used, and free disk space of each file system passed in. If no parameter is carried, all loaded file systems are displayed.
usage: df [-HPkhi] [-t type] [FILESYSTEM ...]
duDisplays the disk usage with files and directories.
usage: du [-d N] [-askxHLlmc] [file...]
ejectEjects a device, which is /dev/cdrom by default.
usage: eject [-stT] [DEVICE]
freeDisplays the total, available, and used amount of physical memory and swap space.
usage: free [-bkmgt]
freeramdiskReleases all memory of a specified RAM disk.
usage: freeramdisk [RAM device]
fsfreezeFreezes or unfreezes a file system.
usage: fsfreeze {-f |-u} MOUNTPOINT
fstypePrints the type of a file system.
usage: fstype DEV...
fsyncSynchronizes the file status with the storage device.
usage: fsync [-d] [FILE...]
i2cdetectDetects an I2C device.
usage:
 i2cdetect [-ary] BUS [FIRST LAST]
 i2cdetect -F BUS
 i2cdetect -l
i2cdumpDumps all I2C registers.
usage: i2cdump [-fy] BUS CHIP
i2cgetReads an I2C register.
usage: i2cget [-fy] BUS CHIP ADDR
i2csetWrites data to an I2C register.
usage: i2cset [-fy] BUS CHIP ADDR VALUE... MODE
losetupSets a loop device.
usage: losetup [-cdrs] [-o OFFSET] [-S SIZE] {-d DEVICE... |-j FILE |-af |{DEVICE FILE}}
lspciDisplays PCI device information.
usage: lspci [-ekmn] [-i FILE ]
lsusbDisplays USB device information.
usage: lsusb
makedevsCreates a series of special files, including block device files and character device files.
usage: makedevs [-d device_table] rootdir
mountMounts a new file system to the directory. If no parameter is carried, the existing mounts are displayed.
usage: mount [-afFrsvw] [-t TYPE] [-o OPTION,] [[DEVICE] DIR]
mountpointChecks whether a directory or device is a mount point.
usage:
 mountpoint [-qd] DIR
 mountpoint [-qx] DEVICE
syncWrites the cached data to a disk.
usage: sync
sysctlReads and writes the system control data in /proc/sys.
usage: sysctl [-aAeNnqw] [-p [FILE] |KEY[=VALUE]...]
tunctlCreates or deletes a TUN or TAP device.
usage: tunctl [-dtT] [-u USER] NAME
vconfigCreates or deletes a virtual Ethernet device.
usage: vconfig COMMAND [OPTIONS]
umountUnmounts a file system.
usage: umount [-a [-t TYPE[,TYPE...]]] [-vrfD] [DIR...]

Network Operations

CommandDescription
ftpget/ftpputCommunicates with an FTP server and supports operations such as reading, writing, and listing files. The ftpget command contains the -g option. The ftpput command contains the -s option.
usage: ftpget/ftpput [-cvgslLmMdD] [-p PORT] [-P PASSWORD] [-u USER] HOST [LOCAL] REMOTE
ifconfigDisplays or configures a network interface.
usage: ifconfig [-aS] [INTERFACE [ACTION...]]
nbd-clientCreates an NBD client.
usage: nbd-client [-ns] HOST PORT DEVICE
netstatDisplays network information.
usage: netstat [-pWrxwutneal]
ping/ping6Checks network connectivity. The ping6 command contains the -6 option.
usage: ping/ping6 [OPTIONS] HOST
sntpRuns an SNTP client.
usage: sntp [-saSdDqm] [-r SHIFT] [-m ADDRESS] [-p PORT] [SERVER]
telnetConnects to a Telnet server.
usage: telnet HOST [PORT]
traceroute/traceroute6Traces the path that a message takes from your PC to a host. The traceroute6 command contains the -6 option.
usage: traceroute [-46FUIldnvr] [-f 1ST_TTL] [-m MAXTTL] [-p PORT] [-q PROBES] [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-g GATEWAY] [-i IFACE] [-z PAUSE_MSEC] HOST [BYTES]
usage: traceroute6 [-dnrv] [-m MAXTTL] [-p PORT] [-q PROBES][-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-i IFACE] HOST [BYTES]
wgetDownloads resources from the network.
usage: wget [OPTIONS]... [URL]
[OPTIONS] = --max-redirect x -d -O filename -p data

File Operations

CommandDescription
awkFilters and analyzes document content.
usage: awk [-F sepstring] [-v assignment]... program [argument...]
 or: awk [-F sepstring] -f progfile [-f progfile]... [-v assignment]... [argument...]
base64Uses the Base64 algorithm for encryption and decryption.
usage: base64 [-di] [-w COLUMNS] [FILE...]
basenameReturns the non-directory portion of a path name after removing its suffix.
usage: basename [-a] [-s SUFFIX] NAME... |NAME [SUFFIX]
bunzip2Decompresses a .bz file.
usage: bunzip2 [-cftkv] [FILE...]
bzcatDecompresses a listed file to the standard output.
usage: bzcat [FILE...]
catCopies (Concatenates) a file to a standard output device. If no file is specified, the command reads from the standard input device. "-" indicates a standard input device.
usage: cat [-etuv] [FILE...]
chattrModifies the file attributes of a Linux Ext2 file system.
usage: chattr [-R] [-+=AacDdijsStTu] [-v version] [File...]
chconModifies the SELinux security context of a file.
usage: chcon [-hRv] CONTEXT FILE...
chgrp/chownModifies the group of a file.
usage: chgrp/chown [-RHLP] [-fvh] group file...
chmodChanges the access mode of a file (recursively with -R).
usage: chmod [-R] MODE FILE...
cksumOutputs the checksum, length, and file name of a file using 32-bit CRC algorithm. If no file is specified, the command reads from the standard input device. "-" indicates a standard input device.
usage: cksum [-IPLN] [file...]
cmpCompares the contents of two files. (If only one file is specified, the command compares the file contents with the contents of the standard input device). You can specify whether to skip a certain number of bytes at the beginning.
usage: cmp [-l] [-s] FILE1 [FILE2 [SKIP1 [SKIP2]]]
commReads the contents from FILE1 and FILE2 in sequence and outputs three text columns: lines only in FILE1, lines only in FILE2, and lines in both files. "-" indicates a standard input device.
usage: comm [-123] FILE1 FILE2
countCopies the standard input device to the standard output device and displays a simple progress indicator to the standard error output stderr.
usage: count
cpCopies the contents from SOURCE to DEST. If there are multiple sources, DEST must be a directory.
usage: cp [-adfHiLlnPpRrsTv] [--preserve=motcxa] [-t TARGET] SOURCE... [DEST]
cpioReads and writes files from the cpio archive in the newc format.
usage: cpio -{o|t|i|p DEST} [-v] [--verbose] [-F FILE] [--no-preserve-owner]
 [ignored: -mdu -H newc]
crc32Outputs the CRC32 checksum of each file.
usage: crc32 [file...]
cutPrints selected parts of lines from each file to the standard output device. Each selection list is separated by a comma(,), which can be a number (counting from 1) or a dash-separated range (where X- indicates from X byte to the end byte of a line, and -X indicates from the 1st byte to X byte of a line).
usage: cut [-Ds] [-bcfF LIST] [-dO DELIM] [FILE...]
ddConverts and copies a file. It can be used to create disk mirroring, back up data, and convert character encoding.
usage:
  dd [if=FILE] [of=FILE] [ibs=N] [obs=N] [iflag=FLAGS] [oflag=FLAGS]
  [bs=N] [count=N] [seek=N] [skip=N]
  [conv=notrunc|noerror|sync|fsync] [status=noxfer|none]
diffCompares files or folders and outputs their differences.
usage: diff [-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2
dirnameDisplays the directory portion of a path.
usage: dirname PATH...
dos2unixConverts the newline format in a file from DOS "\r\n" to Unix "\n". If no file is specified, the command reads from the standard input device. "-" indicates a standard input device.
usage: dos2unix [FILE...]
echoWrites each parameter to the standard output device. Each parameter is separated by a space followed by a newline.
usage: echo [-neE] [args...]
grep/egrep/fgrepDisplays the lines that match a regular expression. If -e is not specified, the first parameter is the regular expression to match. If no file is specified (or the file name is "-"), the command reads from the standard input device. If a match is found, 0 is returned. If no match is found, 1 is returned. If an error occurs during the command execution, 2 is returned.
The egrep command has the -E option, and the fgrep command has the -F option. The -E and -F options cannot be used at the same time.
usage: grep/egrep/fgrep [-EFrivwcloqsHbhn] [-ABC NUM] [-m MAX] [-e REGEX]... [-MS PATTERN]... [-f REGFILE] [FILE]...
gzipCompresses a file.
usage: gzip [-19cdfk] [FILE...]
expandExpands a tab to a space based on the input parameter.
usage: expand [-t TABLIST] [FILE...]
fallocateReserves space for a file in a file system.
usage: fallocate [-l size] [-o offset] file
fileChecks a file and describes its content type.
usage: file [-bhLs] [file...]
findFinds a file in the directory.
usage: find [-HL] [DIR...] [<options>]
flockManages an advisory lock.
usage: flock [-sxun] fd
fmtReformats the input to a wordwrap of a given line length, preserves the existing indentation level, and writes it to the standard output device.
usage: fmt [-w WIDTH] [FILE...]
gunzipDecompresses a file. If no file is specified, the command decompresses the standard input device as a standard output device. After the command is successfully executed, the input file is deleted and replaced with a new file without the file name extension .gz.
usage: gunzip [-cfk] [FILE...]
headCopies the first line in a file to the standard output device. If no file is specified, the command reads from the standard input device. "-" indicates a standard input device.
usage: head [-n number] [file...]
hexeditEdits a hexadecimal file. All modifications are written to disk immediately.
usage: hexedit FILENAME
iconvConverts the encoding format of a file.
usage: iconv [-f FROM] [-t TO] [FILE...]
inotifydRuns a specified program when a file system event occurs.
usage: inotifyd PROG FILE[:MASK] ...
installCopies a file and sets its attributes.
usage: install [-dDpsv] [-o USER] [-g GROUP] [-m MODE] [-t TARGET] [SOURCE...] [DEST]
linkCreates a hard link for a file.
usage: link FILE NEWLINK
lnCreates a soft or hard link between FROM and TO.
usage: ln [-sfnv] [-t DIR] [FROM...] TO
lsLists the files or folders in the current directory.
usage: ls [-ACFHLRSZacdfhiklmnpqrstux1] [--color[=auto]] [directory...]
lsattrLists the file attributes on the Linux file system. The flag letters are defined in the chattr help.
usage: lsattr [-Radlv] [Files...]
lsofLists all open files that belong to the active processes, or lists the processes that use the listed file.
usage: lsof [-lt] [-p PID1,PID2,...] [FILE...]
md5sumCalculates the hash of each input file. If no file is specified, the command reads from the standard input device. Each input file outputs a line of hash followed by a file name.
usage: md5sum [-bcs] [FILE]...
mkdirCreates one or more directories.
usage: mkdir [-vp] [-m mode] [dirname...]
mkfifoCreates a FIFO file (named pipe).
usage: mkfifo [NAME...]
mkswapCreates a swap space in Linux.
usage: mkswap [-L LABEL] DEVICE
mktempSafely creates a file DIR/TEMPLATE and prints its name.
usage: mktemp [-dqu] [-p DIR] [TEMPLATE]
mknodCreates a special file (b is a block device, c or u is a character device, and p is a named pipe).
usage: mknod [-m MODE] NAME TYPE [MAJOR MINOR]
moreViews a file one page at a time.
usage: more [FILE...]
mvMoves or renames a file.
usage: mv [-finTv] [-t TARGET] SOURCE... [DEST]
nlAdds a line number to an input file.
usage: nl [-E] [-l #] [-b MODE] [-n STYLE] [-s SEPARATOR] [-v #] [-w WIDTH] [FILE...]
odDumps data in octal/hexadecimal format.
usage: od [-bcdosxv] [-j #] [-N #] [-w #] [-A doxn] [-t acdfoux[#]]
pasteMerges corresponding lines from each input file.
usage: paste [-s] [-d DELIMITERS] [FILE...]
patchApplies a diff file to one or more files.
usage: patch [-d DIR] [-i file] [-p depth] [-Rlsu] [--dry-run]
pgrepSearches for a process. PATTERN is an extended regular expression used to check command names.
usage: pgrep [-clfnovx] [-d DELIM] [-L SIGNAL] [PATTERN] [-G GID,] [-g PGRP,] [-P PPID,] [-s SID,] [-t TERM,] [-U UID,] [-u EUID,]
printfUses printf in C to format and print parameters based on the FORMAT.
usage: printf FORMAT [ARGUMENT...]
pwdPrints the working (current) directory.
usage: pwd [-L |-P]
readaheadPreloads a file to the disk cache.
usage: readahead FILE...
readlinkPrints what the symbolic link points to if no options are carried. If it is not a symbolic link, an error is returned.
usage: readlink FILE...
realpathDisplays the standard absolute path name.
usage: realpath FILE...
revOutputs each line in reverse order.
usage: rev [FILE...]
rmRemoves a file.
usage: rm [-fiRrv] FILE...
rmdirRemoves one or more directories.
usage: rmdir [-p] [dirname...]
sedStream editor that applies the edit script to the input line.
usage: sed [-inrzE] [-e SCRIPT]... |SCRIPT [-f SCRIPT_FILE]... [FILE...]
seqCounts in ascending order from the beginning (specified by first) to the end (specified by last). If no parameter is carried, the default value is 1. The parameter can be a negative number or a floating point number.
usage: seq [-w |-f fmt_str] [-s sep_str] [first] [increment] last
setfattrWrites POSIX extended attributes.
usage: setfattr [-h] [-x |-n NAME] [-v VALUE] FILE...
sha1sum/sha256sumCalculates the SHA hash value.
usage: sha?sum [-bcs] [FILE]...
shredDeletes a file securely (overwrites the file content with random data).
usage: shred [-fuz] [-n COUNT] [-s SIZE] FILE...
sortSorts all lines of text from the input file (or standard input device) to the standard output device.
usage: sort [-Mbcdfginrsuz] [FILE...] [-k#[,#[x]] [-t X]] [-o FILE]
splitCopies input (or standard input device) data to a series of output (or "x") files with alphabetically increasing suffix (aa, ab, ac, ... az, ba, bb...).
usage: split [-a SUFFIX_LEN] [-b BYTES] [-l LINES] [INPUT [OUTPUT]]
statDisplays the status of a file or file system.
usage: stat [-tfL] [-c FORMAT] FILE...
stringsDisplays printable strings in a binary file.
usage: strings [-fo] [-t oxd] [-n LEN] [FILE...]
tacOutputs lines in reverse order.
usage: tac [FILE...]
tailCopies the last lines in a file to the standard output device. "-" indicates a standard input device.
usage: tail [-n|c NUMBER] [-f] [FILE...]
tarCreates, extracts, or lists files in a .tar file.
usage: tar [-cxt] [-fvohmjkOS] [-XTCf NAME] [FILES]
teeCopies the standard input device to each listed file, and also to the standard output device. "-" indicates a standard output device.
usage: tee [-ai] [file...]
touchUpdates the access and modification time of each file to the current time.
usage: touch [-amch] [-d DATE] [-t TIME] [-r FILE] FILE...
truncateSets the length of the file, sparsely expanding if necessary.
usage: truncate [-c] -s SIZE file...
uniqReports or filters output duplicate lines in a file.
usage: uniq [-cduiz] [-w maxchars] [-f fields] [-s char] [input_file [output_file]]
unix2dosConverts the newline format from Unix "\n" to DOS "\r\n". If no file is specified, the command reads from the standard input device. "-" indicates a standard input device.
usage: unix2dos [FILE...]
unlinkRemoves a file.
usage: unlink FILE
uudecodeDecodes a file from the standard input device (or INFILE).
usage: uudecode [-o OUTFILE] [INFILE]
uuencodeEncodes data on a standard input device (or file) and outputs the encoded data to a standard output device. The output contains encode-filename.
usage: uuencode [-m] [file] encode-filename
wcCounts the number of lines, words, and characters in the input.
usage: wc -lwcm [FILE...]
whichSearches $PATH for executable files that match the specified file name.
usage: which [-a] filename ...
xxdDisplays the file content in hexadecimal format. If no file is specified, the command reads from the standard input device.
usage: xxd [-c n] [-g n] [-i] [-l n] [-o n] [-p] [-r] [-s n] [file]
zcatDecompress the file to the standard output device. It is similar to gzip -dc.
usage: zcat [FILE...]

FAQs

What should I do if "Unknown command xxx" is displayed?

If the error message "Unknown command xxx" is displayed when you enter xxx, toybox xxx, or help xxx in the command line, the toybox does not support the xxx command.

If the command is described in this topic, the command is not compiled. You are advised to ask questions in the OpenHarmony official forum.

What should I do if "Operation not permitted" or "Permission denied" is displayed?

Toybox contains a large number of commands for operating files and processes. If you do not have the permission on the operated object, an error is reported.

  1. The permission is missing. Check whether you have the read, write, and execute permissions on the file and its folder.
  2. SELinux interception. You can search for the keyword "avc: denied" in the kernel log. Example: If error message similar to "avc: denied { xxx } for comm='ls' xxxxxx" is displayed, the ls command triggers SELinux interception.

If the permission is missing and you need to run this command, you are advised to ask questions in the OpenHarmony official forum.

What should I do if other standard Linux errors are reported?

Most toybox commands are used to call the kernel. When an error occurs, perror is used to print the text corresponding to the Linux kernel error code. Common errors include "File exists"/"Not a directory"/"Read-only file system". These errors are standard Linux errors. You can query the error causes by referring to related Linux documents. Check whether the command parameters or command format is correct based on the error information.

Example: When a file is created in a read-only file system, the error message "Read-only file system" is displayed. The cat command can be used to print a file. If you use this command to print a directory, the error message "Is a directory" is displayed. If you run the ls command to view a file or directory that does not exist, the error message "No such file or directory" is displayed.

What should I do if a command does not comply with the toybox description?

If the command parameters entered in the shell are inconsistent with the toybox command parameters, the possible causes are as follows:

  1. The shell implementation instead of toybox is invoked.

For commands such as time, test, pwd, realpath, ulimit, and kill, shell uses its own implementation. To invoke a toybox command, use the format of toybox [command] [arguments...].

  1. The device does not configure this command for toybox, but has another implementation.

To invoke a toybox command, use the format of toybox [command] [arguments...].

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Debugging Tools

harmony 鸿蒙Ability Assistant

harmony 鸿蒙Account Manager

harmony 鸿蒙Advanced Notification Manager

harmony 鸿蒙App Check Tool

harmony 鸿蒙Access Token Manager

harmony 鸿蒙Bundle Manager

harmony 鸿蒙Common Event Manager

harmony 鸿蒙devicedebug

harmony 鸿蒙EDM

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/sE8r4D