I may check my path using:
echo $PATH
To learn how to change your PATH, or add your current directory to it, see the next answer.
If my executable is lost somewhere in the directory tree, I may want to find it using (for example):
find / -name "netscape"
to find a file named "netscape", starting the search from the root directory "/". You may be able to achieve the same result faster using:
locate netscape
(Locate runs faster because it relies on a pre-built database of files on your system. This database is updated by a background "cron" process that normally runs at night, so don't count on locate to find a file if you regularly switch off your computer for the night, or you are searching for a file that you have just installed.)
Please note that the PATH is normally different for root than for the regular users (root's PATH includes /sbin and /usr/sbin whereas users' don't). Therefore users cannot execute commands located in the "sbin" directories unless they specify the full path to the command. Also, if you become a superuser by executing the su command, you inherit the user's PATH, and to execute the command located in sbin, you need to specify the full path.
Conversely, if I need to learn where an executable which is on my PATH is located on your system (i.e., the executable runs by typing its name anywhere in the system, but I would like to know where it is located), I may use something like this:
which netscape
which will show the full PATH to the executable program called "netscape" (if one exists).
The third possibility: maybe the file is not executable. If it should be, change the permissions to make it executable. E.g. (as root or the user who owns the file):
chmod a+x my_file
will make the file "my_file" executable for all users. Check if it worked using:
ls -l my_file
Read here(lnag_basics.html#file_permissions) if you don't understand the output of this command or the whole "third possibility".
Please note that under Linux (or UNIX), the file extension (for example .exe or .com or .bat) does not make the file executable. The file needs an "executable file access mode" which is not unlike a "file attribute" under DOS.
4.1.5 How can I change the PATH?
Typically, you don't have to change your PATH, but it very useful to understand what PATH is.
The PATH is the list of directories which are searched when you request the execution of a program. You can check your PATH using this command:
echo $PATH
which, on my system , shows the PATH for the user "yogin" to be:
/opt/kde/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/yogin/bin
The ":" is a separator, therefore the above PATH represents a list of directories as follows:
/opt/kde/bin
/usr/local/bin
/bin
/usr/bin
/usr/X11R6/bin
/home/yogin/bin
Here is the output from the command "echo $PATH" run on my system on the account "root":
/opt/kde/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
You can change the PATH for all users on the system by editing the file /etc/profile and adjusting (as root) the line starting with "PATH=". I do it using the pico editor (as root):
pico -w /etc/profile
(The option -w turns off the wrap of long lines.)
Re-login for the change to take effect. To set up the PATH for an individual user only, edit the file /home/user_login_name/.bash_profile (please note the dot in front of the filename--files starting with a dot are normally invisible, you have to use ls -a to see them).
If you really want to have the current directory on your PATH, add "." (dot) to your PATH. When used in the place when directory name is expected, a dot means "the current directory". The specification for the path in /etc/.bash_profile may then look like this:
PATH="$PATH:$HOME/bin:"."
export PATH
This command takes the contents of the environmental variable called PATH (as set for all users

