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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
02-02-2005, 02:17 PM
|
#1
|
LQ Newbie
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20
Rep:
|
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!
|
|
|
02-02-2005, 02:18 PM
|
#2
|
Senior Member
Registered: Sep 2004
Location: Savannah, GA
Distribution: Ubuntu, Gentoo, Mythbuntu, ClarkConnect
Posts: 1,154
Rep:
|
put it in your rc file -- with bash, use ~/.bashrc
|
|
|
02-02-2005, 02:24 PM
|
#3
|
LQ Newbie
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20
Original Poster
Rep:
|
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?
|
|
|
02-02-2005, 02:35 PM
|
#4
|
Senior Member
Registered: Mar 2004
Location: Munich
Distribution: Ubuntu
Posts: 3,517
Rep:
|
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...
|
|
|
02-02-2005, 02:55 PM
|
#5
|
LQ Newbie
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20
Original Poster
Rep:
|
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.
|
|
|
02-02-2005, 03:03 PM
|
#6
|
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973
Rep:
|
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..).
|
|
|
02-02-2005, 03:12 PM
|
#7
|
LQ Newbie
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20
Original Poster
Rep:
|
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
|
|
|
02-02-2005, 03:17 PM
|
#8
|
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973
Rep:
|
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.
|
|
|
02-02-2005, 03:44 PM
|
#9
|
LQ Newbie
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20
Original Poster
Rep:
|
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.
|
|
|
02-02-2005, 08:09 PM
|
#10
|
LQ Guru
Registered: Jan 2002
Posts: 6,042
Rep:
|
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.
|
|
|
02-03-2005, 12:27 AM
|
#11
|
LQ Newbie
Registered: Jan 2005
Distribution: Mandriva 2006
Posts: 20
Original Poster
Rep:
|
Thank you!
This is exactly what I've been trying to find.
|
|
|
02-03-2005, 12:59 AM
|
#12
|
Senior Member
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 10:05 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|