LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 07-12-2008, 05:32 AM   #1
hiteshthappa
LQ Newbie
 
Registered: Jul 2008
Posts: 12

Rep: Reputation: 0
Lightbulb 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.
 
Old 07-12-2008, 05:34 AM   #2
reddazz
Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 73
You edit the file using a text editor and add something like
Code:
export PATH=$PATH:/new/path/bin
 
Old 07-12-2008, 05:38 AM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
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.
 
Old 07-12-2008, 09:20 AM   #4
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Quote:
Originally Posted by jschiwal View Post
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 09:23 AM.
 
Old 07-15-2008, 09:59 PM   #5
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
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).
 
  


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 to set path? permanently AVD_ZM Ubuntu 5 03-06-2007 05:41 PM
edit value of PATH permanently rsumbeling Linux - General 2 12-13-2004 11:57 AM
Store PATH variable permanently Skute Linux - Software 8 01-15-2004 05:05 PM
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


All times are GMT -5. The time now is 01:57 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration