6.2. Running programs

If you try to run your compiled program (which we’ll call lab0) by typing lab0 at the prompt, you’ll receive this message:

lab0: Command not found.

When you type a command at the prompt, the shell checks all directories listed in the PATH environment variable (which you can view by typing echo $PATH) to see if it is present there. If the shell can’t find it, it will print the message listed above.

By default, the current directory (.) is not included in the PATH, and although you can add it,[43] it is much easier (and strongly recommended) to simply type ./lab0 at the prompt instead,[44] specifying that the shell should check the current directory for lab0.



[43] But see “Shell Startup File Elements” under “User Environments” in Brian Ward's How Linux Works (San Francisco: No Starch Press, 2004) for why you shouldn't add . to the PATH.

[44] Recall from Table 3.2, “Common symbols from the file system” that . (a period) stands for the current directory.


Back to Guide main page