What Is a Command?
We’ve said that Unix offers a huge number of
commands and that you can add new ones. This makes it radically
different from most operating systems, which contain a strictly
limited table of commands. So what are Unix
commands, and how are they stored? On Unix, a command is simply a file. For instance,
the ls command is a binary file located in the
directory bin. So, instead of
ls, you could enter the full pathname, also known
as the absolute pathname:
$ /bin/lsThis makes Unix very flexible and powerful. To provide a new utility, a system administrator can simply install it in a standard directory where commands are located. There can also be different versions of a command—for instance, you can offer a new version of a utility for testing in one place while leaving the old version in another place, and users can choose the one they want.
Here’s a common problem: sometimes you enter a command that you expect to be on the system, but you receive a message such as “Not found.” The problem may be that the command is located in a directory that your shell is not searching. The list of directories where your shell looks for commands is called your path. Enter the following to see what your path is (remember the dollar sign!):
$ echo $PATH
/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/lib/java/bin:\
/usr/games:/usr/bin/TeX:.This takes a little careful eyeballing. The output is a series of pathnames separated by colons. The first pathname, for this particular ...