0

Busybox creates those links linking to /bin/busybox.

Why are they there and what are they used for?

tkausl
  • 13,686
  • 2
  • 33
  • 50
grerrg
  • 23
  • 2
  • [They're used for testing in shell scripts](https://unix.stackexchange.com/questions/257014/what-is-the-purpose-of-square-bracket-executable). Double brackets has [slightly different (safer) behavior](https://stackoverflow.com/questions/669452/is-double-square-brackets-preferable-over-single-square-brackets-in-ba). – Bacon Bits Sep 25 '18 at 21:00

1 Answers1

0

They're commands used to figure things out in shell scripts. They're usually used to decide between multiple possible actions in shell scripts. For example:

#!/bin/sh

if [ "$1" -eq "5" ]; then
    echo You gave me a five.
else
    echo You didn't give me a five.
fi

The part that starts with [ checks whether the first argument to the script is 5. To do that, it uses the [ command. [[ is similar but has different capabilities.


The link to /bin/busybox is a trick used by several commands on BusyBox. The /bin/busybox program handles the tasks performed by all of those commands, figuring out which command to perform by looking at which command you originally used to start up /bin/busybox.

This is to save some space on the disk by not having to duplicate things like executable file headers and common functionality and so on for each executable file.

Instead, there's only one executable file for a bunch of commands, so there's only one file header and the common functionality only needs to be included in one file, allowing tricks like static linking without a bunch of duplication, which is nice for embedded systems.

Chai T. Rex
  • 2,972
  • 1
  • 15
  • 33
  • It was clear how the brackets are interpreted for test's by the shell. It was more ominous why only open brackets were there. So to me it's kind of like the special folder "." which points to an inode which is basically your upper folder. Brackets however are not reserved. – grerrg Sep 26 '18 at 12:46
  • The last part helped for comprehension Chai T. Rex. Thank you so much. – grerrg Sep 26 '18 at 12:47