Where do commands live?

Most of the “commands” that we use on the Linux command line are in fact programs (which are stored as files) located typically in the /bin or /usr/bin directories. Take the cp command for instance. You can use the “which” command to determine where the cp program is located.

[alice@localhost ~]$ which cp
/usr/bin/cp

Here we can see that the cp program is located in the /usr/bin directory. When we type a command, the shell searches a list of directories to find the command and runs the first one it finds.

Note that / is the top of the file system under Linux. It is also known as the root directory of the file system. The directories /bin, /home, /usr are subdirectories of the root directory of the system. The directories /home/alice and/usr/bin are subdirectories of /home and /usr respectively. We will discuss the layout of the file system in a Linux system in more detail in Chapter 4.