Problem with path and child shells

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:

a) Some Unix tools are at $HOME/mytools directory. Make these tools accessible for use from any directory.
b) Make these tools usable from child shells.
c) How to make them readily usable whenever you login to the UNIX shell.

  1. Relevant commands, code, scripts, algorithms:

echo, PATH, bash

  1. The attempts at a solution (include all code and scripts):

My attempt for a) is PATH=$PATH\: $HOME/mytools
b and c I have noo idea about. :frowning: I know what child shells are, but isn't the mytools already accessible by them? For c, does it want me to change the path to mytools??

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

University of Alabama at Birmingham, Birmingham (AL), US, Taofiq, cs333
do not have a link to class
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Don't think you need the backslash there.

PATH=${PATH}:/$HOME/mytools

To make it accessible to child shells, you have to make sure its in the environment:

export PATH

For C, you have to put it in your ~/.profile or ~/.bashrc or whatever login file your shell uses. See the manual page for your shell.

The following should be acceptable answers:

a. This will add mytools for the current shell. At command prompt, type the following and hit "enter": PATH=$HOME/mytools:$PATH

b. This will add mytools for child shells as well. At command prompt, type the following and hit "enter": export PATH=$HOME/mytools:$PATH

c. To make this permanent, so commands in mytools directory are usable upon login to the UNIX shell (bash), just add "export PATH=$HOME/mytools:$PATH" to your .bashrc file. Most .bashrc files already have this statement, so it would just be a matter of modifying it.

The placement within PATH is significant. The shell searches for commands from left to right as you read the directories in PATH. In my example, I've placed mytools before all other directories so it is searched first. I do this for two reasons:
1. I want commands in mytools to be used before a command with the same name that is in another directory. Generally, this is not a problem as I don't intentionally use an existing command name.
2. Even if I don't have duplicate command names, I want my scripts to be found quickly. By listing mytools at the beginning, it is searched first. This may only be saving microseconds or less, but that's the way I want it.

Otherwise, adding mytools at the end of the PATH statement is certainly acceptable.

Hope this helps...
--majickmann