Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my Android emulator, the /system/bin folder contains several symlinks that point to the toolbox binary:

# ls -l /system/bin
ls -l /system/bin
lrwxr-xr-x root     shell             2012-08-23 07:01 ls -> toolbox
lrwxr-xr-x root     shell             2012-08-23 07:01 lsmod -> toolbox
lrwxr-xr-x root     shell             2012-08-23 07:01 lsof -> toolbox
-rwxr-xr-x root     shell      181002 2012-08-23 07:01 toolbox

My understanding is that 'toolbox' is a binary that is able to do everything that ls, lsmod, lsof etc... can do, and that calling 'ls -l' ends up calling 'toolbox ls -l'.

But what I don't understand is how this works: if 'ls' is indeed a symlink to 'toolbox', then 'ls -l' would become 'toolbox -l', which of course doesn't work.

What am I missing ? (or said differently: what makes 'ls -l' become 'toolbox ls -l' ?)

share|improve this question
up vote 3 down vote accepted

What you're missing is: The application (in your case toolbox) can evaluate how it was called. To make an easy Linux-example: Say you have a script called myscript, and call it with the parameters para1 para2 (i.e. myscript para1 para2), and the script has a line:

echo $0 $1 $1

It would output exactly what you called it: myscript para1 para2. Now make a symlink: ln -s myscript mylink, call mylink para1 para2, and guess what it will "echo": the command line you called. So parsing the command line, based on the symlink your toolbox was called by, it can determine which functionality you were pointing at.

share|improve this answer
OK, now I get what I was really missing: I was thinking that when calling mylink para1, then $0 would be equal to "myscript". Of course, it doesn't work that way at all: $0 is equals to "mylink", so the script can indeed know what the context is. Thanks a lot ! – laurent kubaski Nov 19 '12 at 15:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.