LinuxQuestions.org
Visit Jeremy's Blog.
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 02-02-2005, 02:17 PM   #1
SuperRunt
LQ Newbie
 
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20

Rep: Reputation: 0
Can't permanently change path


I have tried a few things I found searching the net, but it's not working...
I would like to add a directory (from my home directory) to PATH, so the compiler can find my personal libraries.
This is what I've done so far:
$ PATH = $PATH:/home/programs/[name of library]
$ export PATH

$ echo $PATH returns :/home/programs/[name of library]

But it doesn't stay this way!
When I exit and then open a new shell terminal, echo $PATH returns my "old" PATH without the addition.

I read something about changing the bashrc file, but I opened it, and I don't understand what kind of changes I could do...

Thanx!
 
Old 02-02-2005, 02:18 PM   #2
secesh
Senior Member
 
Registered: Sep 2004
Location: Savannah, GA
Distribution: Ubuntu, Gentoo, Mythbuntu, ClarkConnect
Posts: 1,154

Rep: Reputation: 47
put it in your rc file -- with bash, use ~/.bashrc
 
Old 02-02-2005, 02:24 PM   #3
SuperRunt
LQ Newbie
 
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20

Original Poster
Rep: Reputation: 0
Thanx! That was fast!
Still confused...

This is what my ~/.bashrc file looks like:

# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# enable programmable completion features
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi



Where do I put the /home/programs/{name} part?
 
Old 02-02-2005, 02:35 PM   #4
abisko00
Senior Member
 
Registered: Mar 2004
Location: Munich
Distribution: SuSE, Ubuntu
Posts: 3,513

Rep: Reputation: 58
Add a line like you did on console:

Code:
export PATH=$PATH:/home/programs/lib
You may also put this in /etc/bashrc or /etc/profile for global definition.

But now a noob question back: aren't libraries better added to the system by a tool like ldconfig? I thought this method is usually used for calling commands...
 
Old 02-02-2005, 02:55 PM   #5
SuperRunt
LQ Newbie
 
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20

Original Poster
Rep: Reputation: 0
I did that, but it doesn't "stick".
As soon as I close the shell terminal, I'm back to the old PATH.

I don't know anything about Idconfig. Can you use that for "home made" libraries?


By the way:
We should be telling "Norwegian and Swede" - jokes, since I'm Norwegian (even though I'm located in the US)... Juust kidding.
 
Old 02-02-2005, 03:03 PM   #6
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
what exactly is the directory structure? (like /home/programs/????? ( are there only libs in here or executables to?)).

as far as ldconfig, define "home made" libs (are they shared libraries, static, objects, etc..).
 
Old 02-02-2005, 03:12 PM   #7
SuperRunt
LQ Newbie
 
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20

Original Poster
Rep: Reputation: 0
I'll give an example, so I'm sure I give enough info:

One Directory is Printer. It is in ~/programs which I created for this purpose.
Printer has two directories: /include and /lib.
/include has one file named Printer.h, and /lib has one file named Printer.cpp.
These are from my C++ instructor, and are supposed to be used in a program to print to file.

Sorry I'm so vague, I've just been doing this for a couple of weeks...

Thank you
 
Old 02-02-2005, 03:17 PM   #8
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
well, if you add at the bottom of ~/.bashrc the export line above that should work. after you compile Printer.cpp try typing the name of the executable(Printer) and see if it works.
 
Old 02-02-2005, 03:44 PM   #9
SuperRunt
LQ Newbie
 
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20

Original Poster
Rep: Reputation: 0
OK Just making sure
My .bashrc should look like this after I'm done?

# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# enable programmable completion features
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

export PATH = $PATH:/home/programs/Printer

If I need to add on more, can I just add another line?
I REALLY appreciate your help!

Last edited by SuperRunt; 02-02-2005 at 03:45 PM.
 
Old 02-02-2005, 08:09 PM   #10
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Code:
# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# enable programmable completion features
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

export PATH = $PATH:/home/programs/Printer
The code above is ok, but for efficency use:

Code:
# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# enable programmable completion features
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
PATH=$PATH:/home/programs/Printer

export PATH
If you want to add more variables just add them. You can add multiple variables to the same export line. For example if you want a variable BOB be globalized.

Code:
# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# enable programmable completion features
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
PATH=$PATH:/home/programs/Printer
BOB="his name here"

export PATH BOB
The variables PATH and BOB will be exported at the same time.

.bashrc is a BASH script that gets run when you login. There is also .logout (I think) or was it .bash_logout if you want Linux do something like clean up before logging out.
 
Old 02-03-2005, 12:27 AM   #11
SuperRunt
LQ Newbie
 
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20

Original Poster
Rep: Reputation: 0
Thank you!
This is exactly what I've been trying to find.
 
Old 02-03-2005, 12:59 AM   #12
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
You can also put the export PATH = ..... line in the file ~/.bash_profile

.bash_profile is read when you invoke a login shell, .bashrc is read when you invoke a non login shell. I am not 100% sure what an xterm is invoked as.
--Ian
 
  


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
How do I change ROOT's $PATH permanently? lucasrj SUSE / openSUSE 3 01-29-2005 10:31 AM
edit value of PATH permanently rsumbeling Linux - General 2 12-13-2004 11:57 AM
permanently adding to the path hyphenage Linux - General 12 07-16-2003 02:14 AM
setting PATH permanently evian Linux - Software 3 03-14-2003 12:29 PM
How to set PATH permanently chandhru Linux - Newbie 3 09-24-2002 01:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:01 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