Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to export LD_LIBRARY_PATH to system services and all users. System services are run before login, so .bashrc is not applicable. How to achieve this?

share|improve this question
    
Could you elaborate on what is the actual problem you are trying to solve? –  Keith Aug 30 '12 at 0:19
add comment

2 Answers

You don't need to. Add the directory to /etc/ld.so.conf or a new file in /etc/ld.so.conf.d/, depending on distro.

After that, you must run (at least on Redhat) ldconfig as root.

As a word of caution, you need to be careful which libraries you add to the system shared library path (via the environment, ld.so.conf, or putting in /usr/local/lib). In particular, you beware of two different versions of the same library with the same soname. E.g., if you have a libfoo.0.1 (soname libfoo.0) installed via dpkg/rpm/etc., you don't want a libfoo.0.2 (also soname libfoo.0) in your custom library directory.

(It's actually not that easy to pull off a system-wide environment variable. You can get most user logins with /etc/environment. Scripts will depend on your init system, but (for example) with sysv init on Debian, you could put it in /etc/default/rcS. Anything run straight out of inittab, well, I don't think you can.)

share|improve this answer
    
@bahamat I'm guessing due to an edit overlap, you wound up taking out a paragraph from my answer. I'll add it back.. –  derobert Aug 29 '12 at 15:42
    
Nope, I just removed it because "you don't need to" already sums it up and it's much more concise. –  bahamat Aug 29 '12 at 15:50
    
@bahamat Check the edit log, unix.stackexchange.com/posts/46620/revisions ... I think what happened is that we both hit the edit link, then I submitted my change (the extra paragraph), then you submitted your change (which of course didn't include the extra paragraph). Seems like StackExchange ought to detect this and warn loudly, but apparently not... –  derobert Aug 29 '12 at 15:51
    
No, I just explicitly removed that paragraph because I thought it was unnecessary. I didn't make any other changes. Our edits were 6m apart and the one that came after me was 12m later. It wasn't a collision. –  bahamat Aug 29 '12 at 15:57
    
@bahamat Ah, leaving an edit comment would have cleared up the confusion... –  derobert Aug 29 '12 at 16:05
show 2 more comments

You can add every path in the file in /etc/ld.so.conf.d then run :

ldconfig -v 

Then load them.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.