BusyBox @wiki
- GNU GPL licenses. (copyleft)
-
BusyBox 官网 - The Swiss Army Knife of Embedded Linux.
Command Help 你可以看到 busybox 所支持的 COMMANDS(Currently available applets).
busybox <applet> [arguments...] # or
<applet> [arguments...] # if symlinked
- Busybox 仓库 ,官网也有下载。
strip
Strip command is used mostly in situations where you want to produce a production quality object file which contains minimum required information so that it can be light weight. You can also use it if you don’t want your executable or object file to get reverse engineered.
- 10 Linux Strip Command Examples (Reduce Executable/Binary File Size);
- How to strip executables thoroughly?
- 建议在 /bin 下只存放二进制可执行文件,可以统一 strip,减少文件大小。其他文件放到 /etc 下。
版本 version and built-in
-
ash
是嵌入系统 busybox 标配。其 演进路径:(sh) Bourne shell -> (ash) Almquist shell -> (dash) Debian Almquist shell -> 从 dash fork 出 ash 到 embedded systems,符合 POSIX 标准。 - 各类 shell 对照。
-
# /bin/sh --version
BusyBox v1.12.4 (2018-06-20 15:42:22 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands. -
busybox
看版本号
一般地,/bin/sh 指向 busybox(也在 /bin 下);
busybox | grep -m1 ^ | awk '{print$2}'
即可取出版本 v1.13.4;
busybox 命令执行结果的第一行:BusyBox v1.13.4 (2018-07-02 08:54:56 HKT) multi-call binary
。
安全专家 Adam Katz 在 How to get the first line of a file in a bash script? 文章中的回答尽显对 grep、awk、sed 的娴熟掌握。
ls -lF /bin/sh
lrwxrwxrwx 1 510 511 7 Jul 23 09:12 /bin/sh -> busybox*
- # help
Built-in commands:
. : [ [[ alias bg break cd chdir continue echo eval exec exit export false fg hash help jobs kill let local printf pwd read readonly return set shift source test times trap true type ulimit umask unalias unset wait
Linux 内核 和 系统
- LSB(Linux Standard Base)
-
uname -a
print all information
uname -sn
kernel name 和 node hostname。
uname -r
print the kernel release. -
cat /proc/version
查看内核 -
cat /proc/sys/目录文件...
了解这个目录下的内容,可以更好的了解 sysctl。 -
date -Iseconds
2018-06-28T18:17:15+0800,在 bash 中可以作为 HTTP 访问 t 参数。在 CentOS 6.9 也支持。 uptime
-
cat /proc/uptime
This file contains two numbers: the uptime of the system (seconds), and the amount of time spent in idle process (seconds).
示例输出:37601891.24 102994934.46
第一个数值为系统运行的秒数,第2个数值为系统空闲秒数。注意:该示例为4核服务器。 -
cat /proc/stat
文件 /proc/stat 记录了系统启动后的累计cpu信息等。
Various pieces of information about kernel activity are available in the
/proc/stat file.
All of the numbers reported in this file are aggregates since the system first booted.
cat /proc/cpuinfo
# cat /proc/cpuinfo
system type : RTL8672
processor : 0
cpu model : 56321
BogoMIPS : 448.92
tlb_entries : 64
mips16 implemented : yes
- cat /proc/meminfo
# cat /proc/meminfo
MemTotal: 21828 kB
MemFree: 1700 kB
Buffers: 1660 kB
Cached: 7424 kB
SwapCached: 0 kB
Active: 5500 kB
Inactive: 6048 kB
Active(anon): 1100 kB
Inactive(anon): 1592 kB
Active(file): 4400 kB
Inactive(file): 4456 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 2696 kB
Mapped: 2332 kB
Slab: 7100 kB
SReclaimable: 768 kB
SUnreclaim: 6332 kB
PageTables: 364 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 10912 kB
Committed_AS: 34720 kB
VmallocTotal: 1048404 kB
VmallocUsed: 688 kB
VmallocChunk: 1047616 kB
tar
--a
参数
-a, --auto-compress
use archive suffix to determine the compression program.
自动根据后缀识别压缩算法。例如:tar -xavf sapipack.tar.lzma
-
BusyBox 支持 a 参数,自动识别