Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 792
  • Last Modified:

Possible to change "Default" PATH so that /usr/bin is NOT the first?

Hello,

I'm working with Solaris 9 (X86, but I think the situation is the same in SPARC), and it appears that /usr/bin is always the first directory in the default PATH, and I would like to configure things so that another directory (/opt/csw/bin) is at the front of the PATH, before /usr/bin.  What I mean by "default PATH" is the path that the system uses to start processes before a user logs in.  

The reason that I want to do this is that I am trying to upgrade some software (the Metacity window manager, etc.) and am using pkg-get from http://www.blastwave.org.  When I do the pkg-get, it puts the new software in /opt/csw/bin, so when I boot the system or login, instead of starting the new Metacity (and it's associated processes) from /opt/csw/bin, the versions in /usr/bin are always started.

I've been working at this for a number of days and have tried all kinds of things, including enabling the "PATH" and "SUPATH" lines in /etc/default/login, adding to the PATH in /etc/profile, etc., and regardless of what I do, /usr/bin always seems to be at the beginning of PATH.

My understanding is that /usr/bin is hard-coded into the Solaris code somewhere, but that if the "PATH" line in /etc/default/login is uncommented, then that should override the hard-coded PATH, but it doesn't seem to work this way, at least in Solaris 9 X86.

Can anyone here tell me how I can do this?

Thanks,
Jim
0
jimcpl
Asked:
jimcpl
  • 7
  • 4
  • 2
  • +2
1 Solution
 
yuzhCommented:
Modify /etc/profile should work, make it looks like:

#ident  "@(#)profile    1.17    95/03/28 SMI"   /* SVr4.0 1.3   */

# The profile that all logins get before using their own .profile.

trap ""  2 3
PATH=/opt/csw/bin:$PATH
export LOGNAME PATH

....


PS: If the user redefaul their own PATH in their .profile, the deafult PATH will use the
      definition in the .profile.

eg:
      user fred's .profile:

    PATH=/usr/sbin                # commands for application licensed products
    PATH=$PATH:/usr/bin           # other system commands
    PATH=$PATH:/usr/ccs/bin
    PATH=$PATH:/opt/SUNWspro/bin  # Sun WorkShop 5.0 Compiler binaries
    PATH=$PATH:/etc               # system commands
    PATH=$PATH:/usr/lib/nis       # nisping etc
    PATH=$PATH:$DTWINHOME/bin     # DT X-Windows related files
    PATH=$PATH:$OPENWINHOME/bin   # X-Windows related files
    PATH=$PATH:$HOME/bin          # personel solaris binaries
    PATH=$PATH:$HOME/perlbin      # personel perl scripts
    PATH=$PATH:/sbin              # files needed to boot and mount /usr
    PATH=$PATH:/usr/local/bin     # installed utilities
    PATH=$PATH:/usr/local/sbin     # installed utilities
    PATH=$PATH:/usr/apache/bin     # Apache

    It will have sbin in front of /usr/bin.
       

0
 
jimcplAuthor Commented:
Hi yuzh,

As I mentioned in my original question, I already tried that in /etc/ profile, and it doesn't work.  

I still got /usr/bin as the 1st directory in the PATH, and it still picked up /usr/bin/metacity.  

After adding that to /etc/profile, I was (and am) getting in PATH:

/usr/bin:/opt/csw/bin:/usr/sbin:/usr/bin:....

and "ps -ef|grep metacity" shows:

/usr/bin/metacity -sm-client-id=default1

Per my original question, SOMETHING in Solaris is placing the /usr/bin at the beginning, regardless of what I try.

Jim
0
 
jimcplAuthor Commented:
P.S.  I'm starting to think that this is some kind of bug in Solaris.  Everything I've read seems to indicate that the PATH line in /etc/default/login should OVERRIDE what is hard-coded in the software, but like I said, I tried that (many times), and that doesn't seem to be the case....
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
TintinCommented:
Do you set the PATH in your .profile?
0
 
jimcplAuthor Commented:
Tintin,

I've tried that also.  Same thing.

As I mentione dto yuzh, I've also tried /etc/profile and /etc/default/login.

Even after that, if I do a "ps -ef", I can see that it is using /usr/bin for gnome-session and metacity, i.e., I see:

/usr/bin/metacity
/usr/bin/gnome-session

I'm very puzzled by all this.  

I know that I'm not the only one who's using pkg-get.  Their scheme of putting the new executables into /opt/csw/bin may work ok for stuff that a user starts after they login, but there doesn't seem to be a way to get the new version software to work if they're started automatically, since they always seem to be picked up from /usr/bin.  So I keep wondering how anyone else is using this?

Jim
0
 
yuzhCommented:
As I memtion in my previous comment, .profile in  user's home dir can overwritten the default settings, see my example for fred's .profile.
0
 
TintinCommented:
So what setting do you use for PATH in your .profile?

If you have something like

PATH=/opt/csw/bin:$PATH
export PATH

that should give you want you need.
0
 
jimcplAuthor Commented:
yuzh,

Please bear with me.  I think that there is something going on here that I don't understand (ok, that may be obvious!)....

1) I set /opt/csw/bin at the beginning of a line in /.profile AND in /etc/profile:

PATH=/opt/csw/bin:/usr/bin:/usr/sbin:....

2) I booted the system, and get the GUI login.

3) I select to do Command Line Login

4) At the text login, I log in, and do "echo $PATH" and get:

/opt/csw/bin:/usr/bin:/usr/sbin:....

5) I 'exit' and get the GUI login again, and this time, I log in using the GUI login.

6) Once in Gnome, I do a ps and echo:

echo $PATH, I get:

/usr/bin:/opt/csw/bin:/usr/bin:/usr/sbin:........    <<<=== NOTE the /usr/bin is at the beginning again!!

ps -ef I get:

/usr/bin/metacity ....
/usr/bin/gnome-session .....


So, it seems like, when I do a GUI login, SOMETHING is:

1) Starting the Gnome, metacity, etc. processes from the /usr/bin directory and
2) Putting the /usr/bin back in front of the PATH


So, I can clarify my original question:  How do I get /opt/csw/bin to the front of the path in the Gnome environment, and also get the system to start the GUI processes from the /opt/csw/bin directory instead of from the /usr/bin directory?????


FYI, and in case you're wondering, I have tried the following:

1) Go to a command line login
2) Do "mv /usr/bin/metacity /usr/bin/metacity.org"

In other words, physically removed "metacity" from the /usr/bin directory.

This DOES seem to work, but it's not a viable solution, because there are other duplicate executables in the /opt/csw/bin directory, and I don't want to have to physically remove all the 'old' duplicates from /usr/bin manually, and if I happen to "miss" any, I have seen things like system hangs and corrupting my hard drive...

Jim
0
 
jimcplAuthor Commented:
Tintin,

See my 7:22 pm post to yuzh.  Putting it in .profile does work if I do a command line login, but not if I do a GUI login, and the system is not using that .profile to launch the Gnome, metacity, etc. processes.

Jim
0
 
TintinCommented:
Not too familar with Gnome, but most Window managers have their own profile.

Have a look in $HOME/.gconf
0
 
wesly_chenCommented:
Hi,

   There is a file call Xinitrc.gnome (in /etc/dt/config ?), which has some environment variable setting for
gnome. You may want to check that file.

Regards,

Wesly
0
 
ahoffmannCommented:
Solaris uses csh for user shell by default, hence the file to change should be /etc/csh.cshrc and csh.login and ~/.cshrc
Also "GUI login", which GUI are you using, CDE?
0
 
wesly_chenCommented:
For Solaris 9 x86, there are KDE, CDE, and Gnome. He mentioned Gnome.
For C shell, the system wide setting is /etc/.login.

I found /usr/dt/config/Xinitrc.Sun-gnome-2.0-s9u4x-2_0_2-08  <===version number may vary.

There is one line in /usr/dt/config/Xinitrc.Sun-gnome-2.0-s9u4x-2_0_2-08  :
export PATH="/usr/bin:${PATH}:/usr/dt/bin:/usr/openwin/bin"

You need to modify this line for your path (take out /usr/bin).

Regards,

Wesly

0
 
ahoffmannCommented:
for CDE the files are  /usr/dt/conf/sys.dtprofile and  ~/.dtprofile (except someone changed the default files for xinit, xtart, startx, xsession, etc.)
0
 
jimcplAuthor Commented:
Wesly,

That (the Xinitrc file) sounds interesting.  I'll take a look when I get home.

Thanks!

Jim
0
 
TintinCommented:
ahoffman.

Don't know what Solaris systems you use, but *every* Solaris box I've used has /bin/sh as the default shell for users.
0
 
jimcplAuthor Commented:
wesly,

I just accepted your answer.  That file definitely was the one setting the /usr/bin in the PATH.

Thanks,
Jim
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now