You can tell your login session where to look for executables using an environment variable named PATH
, a list of directories separated by a colon.
It has some value set by default, something like this:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
You can also add your own directories, e.g.:
PATH="$HOME/bin:$PATH"
All executables in these directories can be executed directly from anywhere using only its name. echo
is in one of these directories. To find out where exactly run:
$ which echo
/bin/echo
Using a full path to an executable can be useful in some cases, as the PATH
variable may be different depending on the environment. This can cause problems e.g. when calling scripts via cron.