faqts : Computers : Operating Systems : Linux : Shell Commands

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

109 of 131 people (83%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

Operating system: Linux: Variable: Environment: Set: How to set an environment variable in Linux?

Feb 19th, 2006 10:03
Knud van Eeden, Benjamin Roger,


----------------------------------------------------------------------
--- Knud van Eeden --- 27 February 2004 - 03:08 am -------------------

Operating system: Linux: Command: Environment: Set: How to set an 
environment variable in Linux?

---

In general, to set an environment variable in Linux
type on the console command line:

 <name of your environment variable> = <new value>

---

e.g. typing on the console command line:

 MYDATAFILE=/home/johnny

will set the environment variable 'MYDATAFILE' to 'home/johnny'

---
---

In general, to view the current value of an environment variable type 
on
a console command line:

 echo $<name of your environment variable>

---

e.g.

 echo $MYDATAFILE

will show the current value of MYDATAFILE

---
---

In general, if you want to export the value of an environment variable 
to all child processes,
type on the console command line:

 export <name of your environment variable>

---
e.g.

 export $MYDATAFILE

will let the value of $MYDATAFILE be known to all child processes

---
---

Internet: see also:

---

Operating system: Linux: Environment: Variable: Path: Set: How to set 
the PATH variable in Linux?
http://www.faqts.com/knowledge_base/view.phtml/aid/26752/fid/457

---

Operating system: Linux: Environment: Store: File: In which file to 
store the environment variables?
http://www.faqts.com/knowledge_base/view.phtml/aid/26874/fid/445

----------------------------------------------------------------------