The search path and the current directory

Unlike what you're used to in Windows, the current working directory is not automatically part of your search path. This explains why you might be sitting in a directory which contains an executable program you want to run, but when you type the name of that program, you get the annoying error message "Command not found".

If you want to make whatever your current working directory is part of the search path, you should explicitly add the directory name . to your PATH variable (yes, that's a literal period, which stands for "current directory"). That explains the sample search path you saw in the previous section (with a reference to current directory at the very end):

$ echo $PATH
/bin:/usr/bin:/usr/X11R6/bin:/home/username/bin:.
   

Tip

For security reasons, many people will deliberately leave the current directory reference out of their search path, and will run those programs using the form:

$ ./programname
    

Warning

If you choose to add . to your search path for convenience, do not under any circumstances add it near the front; that is just a security disaster looking for a place to happen. Always append it to the end of the path as the search location of last resort.