Setting Path Permanently
This problem is taking up way too much time...
So, I, like many others, want to set a global PATH variable for all users. I know you should do this in /etc/profile, but it doesn't work. In my etc/profile (before the last two lines) I have:
export PS1="[\u@\h \w]\$ "
export PATH=$PATH:/opt/csw/bin
The PS1 variable is always changed (i.e. it looks like I told it to look), but the PATH variable never includes the folder I appended to it. (This is with root and nonroot users). I don't want to mess with .profile, .bashrc, etc. because this is supposed to be for all users. If I can help it, I'd also like to avoid editing /etc/default/login. Thanks in advance for the help.
-Andy
[745 byte] By [
Zyphon] at [2007-11-26 9:46:41]

# 1
> export PS1="[\u@\h \w]\$ "
> export PATH=$PATH:/opt/csw/bin
>
> The PS1 variable is always changed (i.e. it looks
> like I told it to look), but the PATH variable never
> includes the folder I appended to it.
What shell are your user's using?
alan
# 2
If you users are using sh not bash then you need to do the export on a separate line ie
PATH=$PATH:xxxx
export PATH
being able to do the set and export on one line was functionality added in bash thats not in sh.
On linux boxes, sh and bash are the same.
But on solaris sh is old style original sh.
But users should probably be using bash anyway. Its much more useful as an interactive shell.
So I would suggest editing the shell in the password file.
# 3
I figured it out when I went to a text-based login and got errors about setting path. What robert said was exactly the problem. Thanks for the help guys!
# 4
> If you users are using sh not bash then you need to> do the export on a separate line ie> > PATH=$PATH:xxxx> export PATHYou're sayingPATH=blahblahblah; export PATHdoesn't work?alan
# 5
No, he's saying, in sh, you can't say
export PATH=$PATH:........
you have to say
PATH=$PATH:..........
export PATH
or
PATH=$PATH:..........; export PATH
Also, I have another question. When I login to fluxbox or something, and I open up a terminal (loading sh), my PATH isn't set because sh doesn't source .profile or /etc/profile when invoked like that. Is there some file it does source, or some other way to set PATH?
Thanks
# 6
> No, he's saying, in sh, you can't say
>
> export PATH=$PATH:........
>
> you have to say
>
> PATH=$PATH:..........
> export PATH
>
> or
>
> PATH=$PATH:..........; export PATH
Sorry to split hairs but the message says:
===
If you users are using sh not bash then you need to do the export on a separate line ie
PATH=$PATH:xxxx
export PATH
being able to do the set and export on one line was functionality added in bash thats not in sh.
===
The impression is that sh is the same as DOS. Type one command at a time. Bourne shell does allow for multiple commands on one line.
> Also, I have another question. When I login to
> fluxbox or something, and I open up a terminal
> (loading sh), my PATH isn't set because sh doesn't
> source .profile or /etc/profile when invoked like
> that. Is there some file it does source, or some
> other way to set PATH?
Ok, you logon locally to the box. You type sh to invoke bourne shell and your PATH does not carry over to the new shell?
What shell do you originally log into?
alan
# 7
> > you have to say
> >
> > PATH=$PATH:..........
> > export PATH
> >
> > or
> >
> > PATH=$PATH:..........; export PATH
>
> Sorry to split hairs but the message says:
> ===
> If you users are using sh not bash then you need to
> do the export on a separate line ie
>
> PATH=$PATH:xxxx
> export PATH
>
> being able to do the set and export on one line was
> functionality added in bash thats not in sh.
The functionality difference is the ability to do it in a single command, not the ability to place it on one line:
export PATH=xxxx
Even sh can do it in one line as long as they are separate commands (as shown earlier)
export PATH ; PATH=xxxx
> The impression is that sh is the same as DOS. Type
> one command at a time. Bourne shell does allow for
> multiple commands on one line.
Exactly.
--
Darren
# 8
> > Also, I have another question. When I login to
> > fluxbox or something, and I open up a terminal
> > (loading sh), my PATH isn't set because sh doesn't
> > source .profile or /etc/profile when invoked like
> > that. Is there some file it does source, or some
> > other way to set PATH?
>
> Ok, you logon locally to the box. You type sh to
> invoke bourne shell and your PATH does not carry over
> to the new shell?
>
> What shell do you originally log into?
>
> alan
Here's the problem: Say I log in via fluxbox. /etc/profile is run, setting PATH, etc. Now I open a terminal which loads into sh, but does not run /etc/profile or .profile. Unfortunately, there is a script I want run every time I open a new shell session/terminal, and I want to set a few variables, including PATH via .profile. For some reason, probably logical because /etc/profile has already been sourced, opening a shell via terminal doesn't source either .etc.profile or, more importantly, .profile. Is there a way to get it to execute .profile every time I open a terminal? If you answer is to edit the menu and change the actual command opening the terminal, how do you do that in JDS? I couldn't find a way to do it.
Thanks.
# 9
. <-- Grain of Salt
> Here's the problem: Say I log in via fluxbox.
> /etc/profile is run, setting PATH, etc. Now I open
> a terminal which loads into sh, but does not run
> /etc/profile or .profile.
That's why it's called a login script. Even though the file might not be called login, that's what it does. It runs on LOGON, at no other time does it run automatically. You can source it again in the same or different shell.
> .profile. Is there a way to get it to execute
> .profile every time I open a terminal? If you
Sure, logout and then login again. Then the login script is run and things are set via the login script.
Sorry, but it's working exactly how it's supposed to be working. You could search opensolaris.org and see if you can find the source files for whatever shell you're using and then modify it to always run script x whenever the shell is invoked but by default, they don't work that way.
alan