LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   SHELL related question? (https://www.linuxquestions.org/questions/linux-newbie-8/shell-related-question-948800/)

Ajit Gunge 06-06-2012 06:48 AM

SHELL related question?
 
Hi All,
This may be very basic but still want to know how does this work.My requirement is to add a directory say /home/abc to my PATH variable for user xyz.Now I have read on the internet that the best way is to edit the .bash_profile file for the same.I am using ksh but.So the question is do I have to add multiple .*sh_profile files if I am using multiple shells.Also to have the same PATH work for all the shells do I have to add the PATH variable in all the profile files.Also my basic question to add the directory to the path variable.Do I have to add the following entry in the profile file

PATH=$PATH:/data/myscripts and thats it.

Please let me know.

Thanks.

MensaWater 06-06-2012 07:28 AM

ksh is Korn shell so it relies on .profile not .bash_profile or .bashrc which are designed for bash (Borne Again Shell) which can also use .profile. csh (C shell) instead relies on .tcshrc. Each shell may have its own files so it is best to review the man page for the shell you intend to use. (i.e. type "man ksh" for manual page about ksh.)

Note that dot files such as .profile and .bash_profile are in the user's home directory so are unique to each user. If you want do environmental settings/variables for all users using a given shell then you'd edit files in /etc (e.g. /etc/profile for ksh and bash or /etc/csh.cshrc for csh)

Yes adding the PATH as you have it should work. Note that order of directories in PATH variable is important. If for example you had a program with the same name but different functions in each of /bin, /usr/bin and /data/myscripts and echo $PATH displayed:
/bin:/usr/bin:/data/myscripts
It would always run the one in /bin as that was first in your PATH. On the other hand if you had:
/usr/bin:/bin:/data/myscripts
It would always run the one in /usr/bin first.

Usually the above isn't an issue but you need to be aware of it. For example many DB products provide "isql" so it would be important that a DB user for one DB type use the isql provided by that product rather than one for another if you happened to be running more than one DB type on the same server.

Ajit Gunge 06-06-2012 08:25 AM

Thanks for your inputs.


All times are GMT -5. The time now is 11:47 PM.