I'm using busybox in a embedded system, and I would like to check its version. How do I check the busybox version from within busybox?
5 Answers
Invoke the busybox binary as busybox, and you get a line with the Busybox version, a few more lines of fluff, and the list of utilities included in the binary.
busybox | head -1
Most utilities show a usage message if you call them with --help, with the version number in the first line.
ls --help 2>&1 | head -1
- 807,993
- 194
- 1,674
- 2,175
-
what is `2>&1 `, is it in case there are errors, print stderr to stdout as [here](https://stackoverflow.com/a/818265/1705829) – Timo May 14 '21 at 19:42
-
1@Timo Yes, `2>&1` redirects standard error to standard output, and standard output is going through the pipe, so `… --help 2>&1 | …` sends the output through the pipe whether it's on standard output (which is where the help from `--help` normally goes) or standard error (which some programs use, especially programs that don't recognize `--help` but print a help message when they see an option they don't recognize). – Gilles 'SO- stop being evil' May 14 '21 at 19:46
You can check the version on any system running busybox by running any of the commands with the --help flag to see usage. The first line of the usage calls includes a note about the busybox version:
$ cat --help
BusyBox v1.18.4 (2011-03-13 15:36:03 CET) multi-call binary.
Usage: cat [FILE]...
Concatenate FILEs and print them to stdout
If you are not running busybox but have it installed on your system, you can check by instantiating one of the utilities like so:
$ busybox cat --help
(Edit: As Gilles notes you can also call the busybox binary without a command and get the same header)
Lastly, there is also a note at the end of the man page that shows what version it's from:
$ man busybox | tail -n 1
version 1.18.4 2011-03-13 BUSYBOX(1)
-
I'm using busybox in a embedded system. If I type `cat --version` on it, it shows `cat: unrecognized option '--version'`. – The Student Jul 04 '11 at 13:20
-
I also tried with `ls --version` with the same result `ls: unrecognized option '--version'` – The Student Jul 04 '11 at 13:22
-
@Tom, actually @Gilles has the right answer here, it's in the header of anything you run, so running the `busybox` binary directly makes the most sense. Mine only works for the same reason and throws an error besides. I'll correct it. – Caleb Jul 04 '11 at 15:15
-
Since it hasn't been mentioned, sh --help also works.
# sh --help
BusyBox v1.27.1 (2020-06-11 08:53:57 UTC) multi-call binary.
Usage: sh [-/+OPTIONS] [-/+o OPT]... [-c 'SCRIPT' [ARG0 [ARGS]] / FILE [ARGS]]
Unix shell interpreter
# _
- 265
- 2
- 10
Does it not report the version when you connect,
i.e.
telnet 10.10.10.1
BusyBox v0.61.pre (2008.06.11-10:37+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
#
or run (for example)
# busybox ash
BusyBox v1.17.1 (Debian 1:1.17.1-8) built-in shell (ash)
Enter 'help' for a list of built-in commands.
#
- 20,963
- 4
- 61
- 62
Another way to check the busybox version is to look at the raw program file and only display lines that have BusyBox in them
strings $(which busybox) | grep \\\<BusyBox
or
strings /bin/busybox | grep 'BusyBox'
this one also works, it works by looking for a " v" that has a "." after it without a space character between the "v" and the "."
strings /bin/busybox | grep '[ ][v][^ ]*[.]'
I see output that looks like
syslogd started: BusyBox v1.32.0
BusyBox v1.32.0 (2020-11-03 15:21:44 +03)
- 1
- 1