01 / 06
Where is ls?
You have been typing ls all along, but where is ls?
~ $ which ls/bin/lsAn ordinary file called /bin/ls. The /bin you saw on the map in chapter 9.
Which means what you were typing was the short way of writing this.
~ $ /bin/ls the same thingSo why is ls on its own enough? The answer is the variables of last lesson.
~ $ echo $PATH/bin:/sbin:/usr/bin:/usr/sbinThat is the list of places where commands are looked for, four of them, separated by :.
1. look in /bin2. look in /sbin3. look in /usr/bin4. look in /usr/sbinType ls and the shell goes to those four in order, and runs the first thing it finds.
Not magic, was it. It only searches the places written in a variable, from the top.