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-09-2007, 06:40 PM   #1
Raakh
Member
 
Registered: May 2007
Posts: 128

Rep: Reputation: 15
Setting permenant path


how can i set evironment variable permenantly in path

any help will be highly appreciated

thanks & best regards
 
Old 07-09-2007, 06:45 PM   #2
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
If I understand your question this would do it for the bash shell.
Code:
readonly PATH=$PATH
That readonly directive makes the PATH variable permanent at whatever you set it to. The example is making the PATH variable permanently set to whatever it was already set to.

Last edited by stress_junkie; 07-09-2007 at 06:47 PM.
 
Old 07-09-2007, 06:48 PM   #3
garnetlion
LQ Newbie
 
Registered: May 2004
Location: Portland, OR
Distribution: Debian stable on server; Ubuntu Edgy on laptop and at work
Posts: 9

Rep: Reputation: 0
I believe you can edit /etc/bash.bashrc or your local .bashrc, add the following line:
export PATH=PATH,/your/new/path

That should add your new path onto your existing one, rather than clobbering it. That's just off the top of my head; tere may be a better way.
 
Old 07-09-2007, 07:00 PM   #4
Raakh
Member
 
Registered: May 2007
Posts: 128

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by stress_junkie
If I understand your question this would do it for the bash shell.
Code:
readonly PATH=$PATH
That readonly directive makes the PATH variable permanent at whatever you set it to. The example is making the PATH variable permanently set to whatever it was already set to.

and how can I edit mean to say delete something from path??
 
Old 07-09-2007, 07:03 PM   #5
Raakh
Member
 
Registered: May 2007
Posts: 128

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by garnetlion
I believe you can edit /etc/bash.bashrc or your local .bashrc, add the following line:
export PATH=PATH,/your/new/path

That should add your new path onto your existing one, rather than clobbering it. That's just off the top of my head; tere may be a better way.
but how'll i edit

edit /etcbash.bashrc ??
 
Old 07-09-2007, 08:34 PM   #6
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 Raakh
and how can I edit mean to say delete something from path??
Once the variable is readonly you cannot change it. If you want something different than the system default then you have to specify what you want.

If you wanted your PATH variable to be /bin:/usr/bin then you would put this in your /etc/bashrc or in your user account's ~/.bashrc.
Code:
PATH="/bin:/usr/bin"
If you want that to be readonly then you would use the readonly directive as follows.
Code:
readonly PATH="/bin:/usr/bin"
 
Old 07-12-2007, 03:24 AM   #7
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by Raakh
but how'll i edit

edit /etcbash.bashrc ??
You edit the file with a text editor. If you want to edit /etc/bash.bashrc (the file may be /etc/bashrc or something different though), you'll need to be root. Obviously if you want to edit the .bashrc in your home directory, you won't need root priviliges.
 
Old 07-12-2007, 05:06 AM   #8
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 53
I didn't know this readonly command!

Quote:
export PATH=PATH,/your/new/path
Unless for specific need, this should not been put in bashrc.

.bashrc is executed for each subshells.

So you login, /etc/profile is executed only once
->PATH=/bin
You open a terminal in your wm for example, bashrc is executed
->PATH=/bin:/your/new/path
In this terminal you open an subshell (like running any script would do) :
$bash
->PATH=/bin:/your/new/path:/your/new/path

Solution is to put it in a profile file (/etc/profile for example)
 
Old 07-12-2007, 05:30 AM   #9
Raakh
Member
 
Registered: May 2007
Posts: 128

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Nylex
You edit the file with a text editor. priviliges.
this is the main problem with me as I am begginer and have novoice to edit the file.

you mentioned "text editor" could you plz be more specific

Thanks & best regards
 
Old 07-12-2007, 06:10 AM   #10
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
There are many editors avail on Linux.
Pls add your distribution ie Linux name eg Rh Fedora Core, Suse, Debain, whatever to your profile info (info under your name on posts).
Aslo, add your dektop environment ie KDE or Gnome (probably one of those).
anyway, some editores include:
vi, vim, kedit, gedit, kate, nano, pico etc ....
You'll need to learn at least one of those.
The editor that's avail on all Unix style systems is vi, and a lot these days have the option of vim (means vi improved).
Others may or may not be available.
 
  


Reply

Tags
bashrc, path, readonly


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
setting up permenant route on linux aeby Linux - Networking 2 07-03-2007 02:57 PM
Setting the path powerlifter450 Linux - Software 18 07-05-2006 11:46 AM
How to make Virtual IP address permenant with every reboot-------------- pal Linux - Newbie 2 06-10-2005 02:34 AM
making commands permenant cerealdaemon Linux - General 4 05-16-2005 02:02 AM
PATH SETTING webboss Linux - Newbie 2 03-17-2001 06:29 PM


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