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?

195 of 232 people (84%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

Operating system: Linux: Environment: Variable: Path: Set: How to set the PATH variable in Linux?

Feb 26th, 2004 18:12
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 22 November 2003 - 06:19 pm -------------------

Operating system: Linux: Environment: Variable: Path: Set: How to set 
the PATH variable in Linux?

---

The PATH environment variable contains a list of directories used by 
the shell to locate
executable files typed on the command line.

If you then type a command on the command line, each of this 
directories is searched,
from left to right, until the executable with the same name is found.

---
---

The format of the path in general is:

 PATH=<path1>:<path2>:<path3>...

so a list of directories separated by colons

---
---

To set the PATH environment variable:

---

Steps: Overview:

 1. -Open a console

  2. -If necessary login with the wanted userid:

      1. type

          su <your username>

          and supply a password

 2. To check the current value of the PATH
    environment variable, type:

     echo $PATH

    that will show the current path

     e.g.

      /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/roo
t/bin

 3. -To set the new path

     1. to APPEND your new directory at the END of the current path
        type the command:

         PATH=$PATH:<your new directory to add>

          e.g.

           PATH=$PATH:/mydirectory

            will add '/mydirectory' at the end of the existing
            path

     2. to APPEND your new directory at the BEGINNING of the current 
path
        type the command:

         PATH=<your new directory to add>:$PATH

          e.g.

           PATH=/mydirectory:$PATH

            will add '/mydirectory' at the beginning of the existing
            path

     3. to OVERWRITE the current path
        (so use with caution, possibly write down the old path first),
        type the command:

         PATH=<your new directory>

          e.g.

          PATH=$HOME/bin:/bin/:/usr/bin

          ---

          PS do not use spaces

          ---

           $HOME/bin

          and

           /bin

          and

           /usr/bin

---
---

Successfully tested in Linux Red Hat v9

---
---

Internet: see also:

---

Operating system: Linux: Command: Environment: Set: How to set an 
environment variable in Linux?
http://www.faqts.com/knowledge_base/view.phtml/aid/29077/fid/457

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