LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   just saying - hi [ how to set path in solaris permanently ] (https://www.linuxquestions.org/questions/solaris-opensolaris-20/just-saying-hi-%5B-how-to-set-path-in-solaris-permanently-%5D-502662/)

linuxmsg 11-17-2006 08:14 PM

just saying - hi [ how to set path in solaris permanently ]
 
hi all,

this is arvind from india.

I have a question regarding solaris.

# how to set or export path on permanent basis ?
I know PATH=.. and export PATH but it works temporaray,once you restart or logout,you will get old path or by default.
So i need help.Actually i want to set path for perl in solaris 10.
thanks
Arvind

acid_kewpie 11-18-2006 03:57 AM

well that's *not* just saying hi.. that's asking a solaris question. so moved to SOlaris forum.

tronayne 11-18-2006 07:12 AM

You have two choices - system-wide or user.

System-wide; i.e., so every user logging on to the system gets the PATH, add a line in /etc/profile like this:
Code:

PATH=${PATH}:/path-to-application-executable
You may also have to add a line in /etc/profile
Code:

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/path-to-application-libraries
Alternatively, do the same in the .profile file in your home directory; note, however, that you must log out and log back in again for any change to take effect (/etc/profile and your home directory .profile are read once when you login).

You can add multiple lines as shown in /etc/profile or ~/.profile.

If you're using C-Shell, you would put the .profile entry in .login (using C-Shell syntax).

jlliagre 11-18-2006 12:41 PM

Additionaly, you can set the initial users and root PATH in /etc/default/login and /etc/default/su (PATH & SUPATH).

linuxmsg 11-18-2006 11:41 PM

thank.. i will try it and let you know.

regards

arvind

madivad 03-21-2008 02:29 AM

*** DIGGING UP AN OLD POST to a NEW QUESTION ***

I have been looking for where the best place to add to the PATH environment and saw that while editing /etc/X11/gdm/PreSession/DEFAULT there is an alteration to PATH there. I edited it, logged out and back in again, but that didn't do it.

Then I went searching and found this post. I tried tronayne's answer, but that didn't work either (/etc/profile).

I don't have a .profile on the system anywhere.

I don't want to create a new entry, I just want to edit what is already there.

Additionally, my path is not set in either of the locations that jlliagre has indicated (the lines are commented out).

Where can I find where PATH is set?

edit: I have actually gone and created the .profile file in my home directory (it wasn't there - no, it wasn't hidden, it's just not there in ls -al) and added the lines:
Code:

dave@solaris:~# cat .profile
PATH=$PATH:/usr/local/bin:/usr/ccs/bin:/usr/sfw/bin
export PATH
dave@solaris:~#

Still not working

jlliagre 03-21-2008 03:54 AM

Quote:

Originally Posted by madivad (Post 3095685)
Additionally, my path is not set in either of the locations that jlliagre has indicated (the lines are commented out).

Did you try uncommenting and customizing them ?

acid_kewpie 03-21-2008 04:13 AM

madivad, Do NOT dig up old thread for new questions, that's *EXACTLY* what you shouldn't do, in it's most refined and purest form... new question = new thread.

madivad 03-21-2008 04:48 AM

Quote:

Originally Posted by acid_kewpie (Post 3095745)
madivad, Do NOT dig up old thread for new questions, that's *EXACTLY* what you shouldn't do, in it's most refined and purest form... new question = new thread.

My appologies. I wasn't thinking too straight. It SHOULD have read "Digging up an old thread - SAME question" as it is in fact the SAME question.

Should that still be a new thread? I was also trying to show that I had searched forums before posting, but your comment has been taken on board

tronayne 03-21-2008 06:46 AM

OK, once more into the breech: in /etc/profile or ${HOME}/.profile, define an environment variable; e.g., EDITOR=/usr/bin/vi, then export that variable into the environment; i.e., export EDITOR.

Adding on to a previously-defined environment variable: PATH=${PATH}:/usr/local/bin and so on.

Use a previously-defined environment variable: e.g., MYSQLDIR, PATH=${PATH}:${MYSQLDIR}/bin.

If you make any changes in /etc/profile, you must log out and log back in for them to take effect; similarly, if you make changes in your home directory .profile, you ought to log out and log back in for them to take effect.

Oh, yeah, try reading man profile too.

Are you using C-shell, by any chance? If you are, then a ${HOME}/.profile will do nothing. C-shell (if so, you have my sympathy by the way) does these same things in /etc/profile for every user then in ${HOME}/.login and ${HOME}/.cshrc.

To set the path environment variable in ${HOME}/.login, you use something like this
Code:

set path = ( $path /usr/local/bin )
That's the extent of my C-shell knowledge and setting environment variables for it; try man csh if that's the case.

jlliagre 03-21-2008 08:33 AM

Madivad, did you test my previous suggestion ?
http://www.linuxquestions.org/questi...34#post3095734

czezz 03-21-2008 11:07 AM

Make sure that user who is going to use .profile is using /bin/sh SHELL.
To verify that check /etc/passwd.

jlliagre 03-21-2008 11:52 AM

Please don't advise using /bin/sh which is a pain under Solaris. Suggest using /bin/ksh or /bin/bash instead. They use .profile the same way.

/etc/default/login PATH variable is the place to set the initial PATH regardless of what shell is used.

madivad 03-21-2008 02:40 PM

I have tried everyones suggestions so far and it's becoming an awful mess. So far, nothing is working and I thought I would recap.

I am using OpenSolaris and it's the fancy gnome desktop, not the CDE of Solaris (if this makes a difference)

I have tried uncommenting where PATH has been previously commented out

I have created .login and .profile files in my home dir

I have edited /etc/default/login

After EVERY edit I always log out and back in again and this is ALWAYS the result:
Code:

dave@solaris:~$ set | grep PATH
MANPATH=/usr/gnu/share/man:/usr/share/man:/usr/X11/share/man
PATH=/usr/gnu/bin:/usr/bin:/usr/X11/bin:/usr/sbin:/sbin

dave@solaris:~# set | grep PATH
MANPATH=/usr/gnu/share/man:/usr/share/man:/usr/X11/share/man
PATH=/usr/gnu/bin:/usr/bin:/usr/X11/bin:/usr/sbin:/sbin

To test I am doing the above in a terminal window

edit: I have come to the conclusion that at some final stage PATH is being set somewhere without inheriting the existing path. But I am at my wits end trying to find where this is happening

jlliagre 03-21-2008 06:17 PM

Quote:

Originally Posted by madivad (Post 3096227)
I am using OpenSolaris and it's the fancy gnome desktop, not the CDE of Solaris (if this makes a difference)

Can you post the content of /etc/release to clarify ?
Quote:

edit: I have come to the conclusion that at some final stage PATH is being set somewhere without inheriting the existing path. But I am at my wits end trying to find where this is happening
Did you look at the bash files ?
~/.bashrc
/etc/bash.bashrc


All times are GMT -5. The time now is 06:15 PM.