Setting the path: how the shell finds programs

When the user types in the name of a program to run, the shell searches a list of directories for the program and invokes the first such program found. The list of directories to search is specified by the PATH environment variable.

Normally you don't want to override the system settings; instead, append to the current path as shown below,

[alice@localhost]: export PATH="$PATH:/extra/dir"

with new entries delimited with a colon. The setting for the PATH variable goes in the .bash_profile or .bashrc file.

Due to security concerns, typically the current directory is not in your path. So you have to specify the path using the dot notation to run programs in the current directory (as shown below):

./myprog

While that works, we can add the current directory to the PATH so that we do not have to prefix each time with the ./ prefix. Here is the setting.

export PATH=$PATH:.

Make sure to add . to the end of the path (for security reasons). Add this line at the end of your .bashrc file in your home directory.