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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-12-2008, 04:32 AM
|
#1
|
|
LQ Newbie
Registered: Jul 2008
Posts: 12
Rep:
|
permanently store PATH variables
Hi can anyone plz tell me how do i store my PATH variables permanently.
I know thats its something to do with .bash_profile file. but i dont no how how to modify it.

|
|
|
|
07-12-2008, 04:34 AM
|
#2
|
|
Guru
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298
Rep:
|
You edit the file using a text editor and add something like
Code:
export PATH=$PATH:/new/path/bin
|
|
|
|
07-12-2008, 04:38 AM
|
#3
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Add two lines like:
PATH=$PATH:/usr/local/bin
export PATH
This example is for adding /usr/local/bin to PATH.
You might want to check which bash startup variable your distro uses. If there is already a .profile but not a .bash_profile, then use the .profile file instead. My only concern is that .bash_profile will be sourced instead of .profile, missing things added by your .profile command. However, if there is no .profile file in your home directory, go ahead and use .bash_login.
The bash info manual explains which startup scripts are searched for when bash starts up. You probably already read through that.
|
|
|
|
07-12-2008, 08:20 AM
|
#4
|
|
Senior Member
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873
|
Quote:
Originally Posted by jschiwal
You might want to check which bash startup variable your distro uses. If there is already a .profile but not a .bash_profile, then use the .profile file instead. My only concern is that .bash_profile will be sourced instead of .profile, missing things added by your .profile command. However, if there is no .profile file in your home directory, go ahead and use .bash_login.
|
Or to put it another way, different distributions use different startup scripts. You may have to experiment to find the ones that your distribution uses.
The following files are a good bet:
/etc/bashrc
/etc/profile
/etc/profile.d/*
Distributions that I've used are very unreliable about running the files in the $HOME directory at login.
$HOME/.bashrc
$HOME/.profile
$HOME/.alias
On the other hand the files in the /etc directory are likely to be overwritten by a patch or an upgrade.
Last edited by stress_junkie; 07-12-2008 at 08:23 AM.
|
|
|
|
07-15-2008, 08:59 PM
|
#5
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Just a note:
The /etc/profile startup script is for the entire system and not suited for changing your path. In SuSE, you shouldn't edit it at all but edit /etc/profile.local instead. There are also scripts in /etc/profile.d/. This allows an installation program to change global configurations by dropping a script in there. That way the config program can leave the /etc/profile script alone. On some systems that use selinux or apparmour, they may be prohibited from modifying /etc/profile anyway.
The ~/.aliases or ~/.alias file might be sourced by your startup script. It is alway a good idea to actually read your startup scripts to see what get's sourced. Often there is a line that first checks for a scripts existance, and only if it exists runs it. The "if [ -x ..." blocks will name these scripts, and reading ~/.profile or /etc/profile would be a good way to discover others (which may be just for your distro).
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:17 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
|
|