LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-04-2008, 12:17 PM   #16
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,442

Rep: Reputation: 71

Quote:
Originally Posted by Pedroski View Post
OOps, forgot to paste the answer:

peter@vaya:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/lib:/usr/include:/usr/include/jasper
peter@vaya:~$
/usr/lib and the rest that you wanted is already in your path. What is the problem? Did you just want /usr/lib last?
 
Old 06-04-2008, 12:41 PM   #17
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,442

Rep: Reputation: 71
I'm sensing now that you misunderstand how the PATH is used. When you enter a command without an absolute path in the console it searches for the first executable it finds along the PATH. This is why locations like /usr/local/bin,/usr/bin, and /bin are the first ones listed in the PATH.

Do note that if the file isn't executable it won't matter if its location is within the PATH.

Also, /usr/lib shouldn't contain a lot of real executable files, if any, other than libraries. Executable files such as /usr/lib/firefox/firefox usually have a corresponding symlink under one of the bin directories (/usr/bin/firefox -> /usr/lib/firefox/firefox in that case). So, I really don't understand why you would want /usr/lib in your PATH in the first place.

Some special cases might include /usr/lib/java/bin, /usr/lib/java/jre/bin, and /usr/lib/qt/bin. Having these in your PATH might make sense for you, because they have lots of binaries in there. Usually, these kinds of special cases are added in by small files under /etc/profile.d so that if java is removed, for instance, that special case can easily be removed.

/etc/profile.d/jdk.sh is executable and for me it contains
Code:
#!/bin/sh
export JAVA_HOME=/usr/lib/java
export MANPATH="${MANPATH}:${JAVA_HOME}/man"
export PATH="${PATH}:${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin"
 
Old 06-04-2008, 12:57 PM   #18
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 14.04
Posts: 1,520

Original Poster
Rep: Reputation: 42
After restart I get, again:

peter@vaya:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
peter@vaya:~$

even though /etc/profile is as above!! Arrrggghhh!

Any ideas??
 
Old 06-04-2008, 01:03 PM   #19
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 14.04
Posts: 1,520

Original Poster
Rep: Reputation: 42
Ok, so there is no more misunderstanding:

I want, mainly /usr/lib in my PATH. Permanently!

I read, that is achieved by putting it in /etc/profile

Did that, as you can see above.

However, on restart, it's not there............ grrrr!

I can put it there by modifying $PATH in a shell, but that's not the same. It doesn't stay there. Why not??? It's in /etc/profile, and in /home/peter/.bash_profile, as I said above. It should work. It doesn't!! And I've no idea why not!!!
 
Old 06-04-2008, 01:06 PM   #20
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 14.04
Posts: 1,520

Original Poster
Rep: Reputation: 42
/usr/lib contains jasper runtime libraries to make the web-cam work in Kopete. Kopete looks for them, can't find them, complains.
 
Old 06-04-2008, 07:09 PM   #21
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
See this:
Code:
env|sort|grep lib
GTK_PATH=/usr/local/lib/gtk-2.0:/opt/gnome/lib/gtk-2.0:/usr/lib/gtk-2.0
JAVA_BINDIR=/usr/lib/jvm/jre/bin
JAVA_HOME=/usr/lib/jvm/jre
JAVA_ROOT=/usr/lib/jvm/jre
JRE_HOME=/usr/lib/jvm/jre
PATH=/home/chrism/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/lib/qt3/bin
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/opt/kde3/lib/pkgconfig:/opt/gnome/lib/pkgconfig:/opt/gnome/lib/pkgconfig:/opt/gnome/share/pkgconfig
QTDIR=/usr/lib/qt3
Note that all the blah/lib entries are not in $PATH, except for those which actually end in 'bin'.
As said above, you don't have them in $PATH. Kopete or Jasper prob expects an extra env var eg like my QTDIR entry.

HTH
 
Old 06-04-2008, 07:23 PM   #22
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,442

Rep: Reputation: 71
Quote:
Originally Posted by Pedroski View Post
/usr/lib contains jasper runtime libraries to make the web-cam work in Kopete. Kopete looks for them, can't find them, complains.
This sounds like something that could have been taken care at configure time for kopete. I am not familiar with Kopete and jasper, so I don't know if that is true or not.

As chrism01 said, it could also be that you just need to specify a different environment var.

I still don't understand why the PATH is not sticking for you, though. It is almost as if /etc/profile is being ignored completely. I don't have a copy of Debian or any Debian-based distro installed right now, so I don't know why this is happening. Here is something else you can try.

Try creating a small executable script under /etc/profile.d/

/etc/profile.d/jasper.sh
Code:
#!/bin/sh
export PATH="${PATH}:/usr/lib:/usr/include:/usr/include/jasper"
Don't forget to make it executable (chmod +x jasper.sh)

By the way, I don't think the ~/.profile, ~/.bash_profile, ~/.bashrc, etc files will work unless they are executable.
 
Old 06-05-2008, 01:55 AM   #23
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 14.04
Posts: 1,520

Original Poster
Rep: Reputation: 42
Thanks for the help. I'll try the scripts suggested. And it is strange that, having put it in /etc/profile, it doesn't stick. Work on that one.
In desperation I put PATH=$PATH:/usr/lib in my /home/.bashrc That works!! Started this morning and bam! PATH is what I wanted. But maybe only after starting bash? There is a difference between login and ordinary shells I read. What does the rc stand for??
I don't have a file /etc/profile.d, so I'll have to make it.


Something Shadowsnipes said above just made me think, so I checked: /etc/profile is not checked as executable!! That the problem??

I downloaded Kopete with Synaptic Package Manager, which auto installs. Didn't ask me for any paths, enviroment variables or whatever. But then, never does!
All this trouble just because of a girl I met in England!! C'est la vie!
 
Old 06-05-2008, 11:43 AM   #24
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,442

Rep: Reputation: 71
Quote:
Originally Posted by Pedroski View Post
Thanks for the help. I'll try the scripts suggested. And it is strange that, having put it in /etc/profile, it doesn't stick. Work on that one.
In desperation I put PATH=$PATH:/usr/lib in my /home/.bashrc That works!! Started this morning and bam! PATH is what I wanted. But maybe only after starting bash? There is a difference between login and ordinary shells I read.
/etc/profile and ~/.profile will be used when a user logs in and ~/.bashrc will be used when opening an xterm, etc.
Quote:
Originally Posted by man bash
INVOCATION
[...]
When bash is invoked as an interactive login shell, or as a non-inter-
active shell with the --login option, it first reads and executes com-
mands from the file /etc/profile, if that file exists. After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the first one that
exists and is readable.
The --noprofile option may be used when the
shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the
file ~/.bash_logout, if it exists.

When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc
, if that file exists. This
may be inhibited by using the --norc option. The --rcfile file option
will force bash to read and execute commands from file instead of
~/.bashrc.

When bash is started non-interactively, to run a shell script, for
example, it looks for the variable BASH_ENV in the environment, expands
its value if it appears there, and uses the expanded value as the name
of a file to read and execute. Bash behaves as if the following com-
mand were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the PATH variable is not used to search for the file
name.

If bash is invoked with the name sh, it tries to mimic the startup
behavior of historical versions of sh as closely as possible, while
conforming to the POSIX standard as well. When invoked as an interac-
tive login shell, or a non-interactive shell with the --login option,
it first attempts to read and execute commands from /etc/profile and
~/.profile
, in that order. The --noprofile option may be used to
inhibit this behavior. When invoked as an interactive shell with the
name sh, bash looks for the variable ENV, expands its value if it is
defined, and uses the expanded value as the name of a file to read and
execute. Since a shell invoked as sh does not attempt to read and exe-
cute commands from any other startup files, the --rcfile option has no
effect. A non-interactive shell invoked with the name sh does not
attempt to read any other startup files. When invoked as sh, bash
enters posix mode after the startup files are read.
This is why I put all my user specific environment stuff in ~/.profile. My ~/.bashrc simply contains
Code:
if [ -f ~/.profile ]; then
	source ~/.profile
fi
For user specific changes I recommend you do something similar. Try changing your path in ~/.profile (you can use the contents of the script jasper.sh above), and then simply source that file in your ~/.bashrc as shown above. I make both of those files executable.

Quote:
Originally Posted by Pedroski View Post
What does the rc stand for??
'rc' stands for 'run command'.

Quote:
Originally Posted by Pedroski View Post
I don't have a file /etc/profile.d, so I'll have to make it.
It is a directory and not a regular file. If it isn't already there then it might not be used by Debian (surprising again). Actually, I just did a quick google search and it seems that Debian does not officially support profile.d files. You can still use them if you want. You will have to create the /etc/profile.d directory and then add this code snippet to the end of your /etc/profile.
Code:
# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done
unset profile_script
Keep in mind that when you upgrade you might have to put that snippet back in your /etc/profile.

Quote:
Originally Posted by Pedroski View Post
Something Shadowsnipes said above just made me think, so I checked: /etc/profile is not checked as executable!! That the problem??
No, /etc/profile should not need to be executable. I think ~/.profile and ~/.bashrc should be executable. Files under /etc/profile.d/ need to be executable as well.

Quote:
Originally Posted by Pedroski View Post
I downloaded Kopete with Synaptic Package Manager, which auto installs. Didn't ask me for any paths, enviroment variables or whatever. But then, never does!
All this trouble just because of a girl I met in England!! C'est la vie!
Did you install Kopete manually previously?
 
Old 06-05-2008, 07:15 PM   #25
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Actually, .bashrc & .profile are not set executable, they are read and the cmds executed by the login shell.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
export Path=/usr/java:$Path does not seem to work lumix Linux - Newbie 1 03-19-2007 04:11 PM
Do you add to the path line or make a new path in /etc/profile? M$ISBS Linux - Newbie 2 12-13-2006 03:14 PM
Image Path reference in Linux (Absolute path) javabuddy Linux - General 7 06-05-2006 08:45 AM
script to change unix path to windows path in all files csross Programming 8 04-29-2006 02:05 PM
How to Chnage Python's module search path (sys.path)? lramos85 Linux - Software 1 05-02-2004 07:10 PM


All times are GMT -5. The time now is 08:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration