|
||||||
| Forums FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| ARCHIVES - General Questions If your question doesn't fit in any other category below ask in here. |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I am struggling a bit with the best way to add a path for use globally on my SuSE 9.1 system. I assumed that there would be a YAST setting but I have not been able to find one. Google pointed me in the direction of /etc/profile which I opened but that file strongly suggests that I use the profile.local for adding PATH variables. I looked for this file and it did not exist so back to Google. I have since created the /etc/profile.local file and included the following commands.
#profile.local #local system settings #add nessus to PATH variable PATH="$PATH":/usr/local/nessus/bin:/usr/local/nessus/sbin export PATH This appears to work but I end up getting TWO entries for the above directories once I restart my session. Can someone enlighten me please? |
|
|||
|
Patiently waiting to be inlightened.................... ;-)
The more I mess around with installs the more I keep running into this. I'm looking for a 'best practice' suggestion. It seems so simple so maybe I am just dense but any help would be appreciated. |
|
|||
|
I'm not so hot at paths yet, but since no one has pointed out any suggestions ... I run bush by default (I think it may be the default for SuSE) and add the exports and paths to the /home/<user>/.bashrc. Hope that helps or at least points you in a different direction.
|
|
|||
|
What you have looks fine. But I have noticed the same problem with multiple entries in $PATH. It seems that at after a reboot and logging in, that /etc/profile and $HOME/.profile are both getting run twice. Anyone else seeing this problem or know what might be causing it? I fixed the double entry problem by borrowing a function from my old Red Hat install called "pathmunge". I put the following in a file (/local/etc/pathmunge). ################### pathmunge () { if ! echo $PATH | /bin/egrep -q "(^| $1($| " ; thenif [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi fi } shopath () { echo -e ${PATH//:/"\n"} } export pathmunge shopath ###################### Then, within your /etc/profile.local, you could do: . /local/etc/pathmunge pathmunge /usr/local/nessus/bin after pathmunge /usr/local/nessus/sbin after which will add /usr/local/nessus/bin to your $PATH, unless it is already there. The "after" puts it at the end. Leave off the "after" to put the new path at the beginning of $PATH. The "shopath" function is just a convenience to print out $PATH one element per line. Just run the command "shopath" from a shell. (after running the command ". /local/etc/pathmunge" to load the file with the function defs. |
|
|||
|
Quote:
Ok, now to really answer your question (this method may not work on other distributions) -- the reason this happens is because your '/etc/profile' is run twice. I am not sure when these things happen exactly, but I can say for certain from what you see that it is run twice. What can you do? Well, suse exports an environment variable called 'PROFILEREAD' which is set to 'true' when the profile is read once. So, you can test for its value and only set your PATH if this variable is not set already. Something like Code:
if test -z "$PROFILEREAD"; then PATH="$PATH":/usr/local/nessus/bin:/usr/local/nessus/sbin export PATH fi |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|