# Busybox

<figure><img src="/files/GuKCCpKlnxjlrKCGaQIU" alt=""><figcaption><p>มีด Swiss Army Knife</p></figcaption></figure>

BusyBox ได้ถูกพัฒนาขึ้นโดยนาย Bruce Perens ในปี ค.ศ. 1996 ซึ่งเดิมทีถูกนำมาใช้เป็นโปรแกรมช่วยในการติดตั้งและกู้คืนในแผ่นดิสก์เก็ตแบบบูทตัวเองได้ของระบบปฏิบัติการ Debian (bootable Debian Linux system) โดยมีเงื่อนไขว่าลีนุกซ์คอร์เนลและโปรแกรมพื้นฐานทั้งหมดจะมีขนาดรวมกันแล้วไม่เกิน 1.4  MB ถึง 1.7 MB เนื่องจากข้อจำกัดในการเก็บข้อมูลภายในแผ่นดิสก์เก็ตในยุคนั้น ดังนั้นหลักการสำคัญที่จะต้องทำให้ BusyBox มีขนาดเล็กแต่ยังคงเต็มไปด้วยชุดคำสั่งมากมายคือการใช้ส่วนฟังก์ชันพื้นฐานที่เหมือนกันร่วมกันตัวอย่างเช่น ตัว BusyBox จะทำการรวมโปรแกรม grep และ find เป็นโปรแกรมเดียวกันเนื่องจากใช้หลักการค้นหาไฟล์โดยจะเข้าไปถึงภายในไดเรกทอรีทุกไดเรกทอรี (recursive) เช่นเดียวกัน เป็นผลให้ขนาดไฟล์ที่เกิดจากการรวมโปรแกรมทั้งสองลดลงอย่างมาก ดังนั้น BusyBox ก็สามารถใช้หลักการนี้กับโปรแกรมอื่นๆที่มีฟังก์ชันพื้นฐานเดียวกันจากเดิมที่มีขนาดทั้งสิ้น 3.5 MB ก็สามารถลดลงเหลือเพียงไม่เกิน 800 KB เท่านั้นได้&#x20;

ดังนั้น BusyBox จึงกลายมาเป็นเครื่องมือสำคัญที่ถูกนำมาใช้ภายในระบบปฏิบัติการของระบบสมองกลฝังตัวอื่นๆจนถูกตั้งฉายาว่าเป็น “มีดพกพาสารพัดประโยชน์” (Swiss Army Knife) ซึ่งได้รวมชุดโปรแกรมและชุดคำสั่งอรรถประโยชน์ของคำสั่งพื้นฐานต่างๆที่จำเป็นในระบบปฏิบัติการลีนุกซ์ ตัวอย่างเช่น ชุดโปรแกรมที่ใช้จัดการบริการต่างๆของระบบในขณะเครื่องกำลังเริ่มทำงาน (Init program), ชุดคำสั่งจัดการระบบและตั้งค่าระบบ (System & Configuration) เป็นต้น ตัวอย่างคำสั่งใน BusyBox version 1.30 ได้แก่

{% code overflow="wrap" %}

```shell-session
$ busybox                                                                                                        
BusyBox v1.30.1 (Ubuntu 1:1.30.1-7ubuntu3) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

Usage: busybox [function [arguments]...]
   or: busybox --list[-full]
   or: busybox --show SCRIPT
   or: busybox --install [-s] [DIR]
   or: function [arguments]...

	BusyBox is a multi-call binary that combines many common Unix
	utilities into a single executable.  Most people will create a
	link to busybox for each function they wish to use and BusyBox
	will act like whatever it was invoked as.

Currently defined functions:
	[, [[, acpid, adjtimex, ar, arch, arp, arping, ash, awk, basename, bc, blkdiscard, blockdev, brctl, bunzip2, bzcat, bzip2, cal, cat, chgrp, chmod, chown, chpasswd, chroot, chvt, clear, cmp, cp, cpio, cttyhack, cut,date, dc, dd, deallocvt, depmod, devmem, df, diff, dirname, dmesg, dnsdomainname, dos2unix, du, dumpkmap, dumpleases, echo, egrep, env, expand, expr, factor, fallocate, false, fatattr, fgrep, find, fold, free, freeramdisk, fsfreeze, fstrim, ftpget, ftpput, getopt, getty, grep, groups, gunzip, gzip, halt, head,hexdump, hostid, hostname, httpd, hwclock, i2cdetect, i2cdump, i2cget, i2cset, id, ifconfig, ifdown, ifup, init, insmod, ionice, ip, ipcalc, ipneigh, kill, killall, klogd, last, less, link, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger, login, logname, logread, losetup, ls, lsmod, lsscsi, lzcat, lzma, lzop, md5sum, mdev, microcom, mkdir, mkdosfs, mke2fs, mkfifo, mknod, mkpasswd, mkswap, mktemp, modinfo, modprobe, more, mount, mt, mv, nameif, nc, netstat, nl, nologin, nproc, nsenter, nslookup, nuke, od, openvt, partprobe, paste, patch, pidof, ping, ping6, pivot_root, poweroff, printf, ps, pwd, rdate, readlink, realpath, reboot, renice, reset, resume, rev, rm, rmdir, rmmod, route, rpm, rpm2cpio, run-init, run-parts, sed, seq, setkeycodes, setpriv, setsid, sh, sha1sum, sha256sum, sha512sum, shred, shuf, sleep, sort, ssl_client, start-stop-daemon, stat, strings, stty, svc, svok, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac, tail, tar, taskset, tee, telnet, test, tftp, time, timeout, top, touch, tr, traceroute, traceroute6, true, truncate, tty, ubirename, udhcpc, udhcpd, uevent, umount, uname, uncompress, unexpand, uniq, unix2dos, unlink, unlzma, unshare, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, w, watch, watchdog, wc, wget, which, who, whoami, xargs, xxd, xz, xzcat, yes, zcat
```

{% endcode %}

ด้วยแนวคิดการรวมฟังก์ชันพื้นฐานที่ใช้ร่วมกันของชุดคำสั่งต่างๆในระบบปฏิบัติการลีนุกซ์ให้กลายมาเป็น BusyBox เพียงโปรแกรมเดียวนั้น จะสามารถลดขนาดโปรแกรมลงได้ถึง 3 ถึง 4 เท่าเมื่อเทียบกับการใช้โปรแกรมพื้นฐานทั้งหมด ซึ่งจะสังเกตจากการใช้คำสั่ง ls -al ดังรูปข้างล่างว่าทุกคำสั่งจะถูกชี้ (symbolic link) ไปยังโปรแกรม busybox ทั้งสิ้น

<div data-full-width="true"><figure><img src="/files/Q9UXc7qJQUxrIf4oqJ7I" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aic-eec.com/computer-operation-systems/zero-to-linux-hero/anatomy-of-linux-system/busybox.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
