Path

PATH is a Variable of environment systems Unix/Linux/Mac OS X/Windows.

This variable indicates un/des repertory (S) in which will be required the achievable files.

Example

You place an achievable file fichier_ex in /opt/toto/bin .

You place yourselves in an unspecified repertory of your system (via the order Cd ).

If you try to type fichier_ex in the console (or the terminal) it will not be carried out because /opt/toto/bin is not in PATH .

On the other hand if you type /opt/toto/bin/fichier_ex that functions, but it is rather long to write.

It is thus necessary to adjust the variable of environment PATH.

Under Unix/Linux

To visualize the PATH

echo $PATH

one can also use the order

printenv PATH

Separator

The separator is both point (:)

To modify the PATH temporarily

With Shell Bash export PATH=$PATH: /opt/toto/bin

This modification is only temporary (for the session in progress).

To modify the PATH in a permanent way

It is thus necessary to make permanent the modification of the PATH by putting the following line in the file ~/. Bash rc . export PATH=$PATH: /opt/toto/bin

The trap of the current directory

Under Unix, to carry out a file which is in the current directory, one is in general obliged to prefix the order by ". /" , which makes it possible to indicate that the file is in the current directory.

This characteristic astonishes the users who have the practice of Windows (or of old the MS-DOS) where one can directly call a program which is in the current directory.

However, it is a security measure: as example, if a malevolent intruder manages to place a harmful program named ls in the current directory, this program will be carried out as soon as you wish to list the repertory (instead of the order ls being normally in the /bin/ repertory, which him is in the PATH, but which is modifiable only by the administrator of the system).

So despite everything the user wishes to find this " ergonomie" of Microsoft, it is necessary that it adds the way ". /" in its PATH: PATH=$PATH:. /

The basic $PATH in the profile

The basic value of $PATH, for all the login, is defined in the profile: file Shell /etc/profile .

Under Mac OS X

To visualize the PATH

(In Bourne Shell) echo $PATH

Separator

The separator is both point (:)

To modify the PATH temporarily

PATH=" export; $PATH: /opt/toto/bin" This modification is only temporary (for the session in progress).

To modify the PATH in a permanent way

It is necessary to make permanent the modification of the PATH by adding the following line in the User profile (i.e. Shell ~/.profile or ~/.bash_profile according to the type of terminal you use). PATH=" export; $PATH: /opt/toto/bin"

It is also possible to modify directly the PATH of the file /etc/profile (it is necessary to use Sudo or to be in Root).

Under Windows

To visualize the PATH

In one invites of order, launch the order: set path . or echo %PATH%

Separator

The separator is the character semicolon: " ; ".

To modify the PATH temporarily

In one invites of order, use set PATH=%PATH%; c:\opt\toto\bin

This modification is only temporary (for invites of pending order).

To modify the PATH in a permanent way

Two manners are possible:

1- It is necessary to use the modification of the variable of environment PATH in the “advanced” miter of the properties of the work station.

2- To use an order MS-DOS (which is more practical for a use in a script). Here an example of use:

- > the goal being to add C:\Lotus\Notes to the variable of environment PATH in a permanent way.

REG. ADD " HKLM \ SYSTEM \ CurrentControlSet \ Control \ Session Manager \ Environment" /v Path /d " %PATH%; C:\Lotus\Notes " /f

Options of REG. ADD

/f (force) makes it possible to prevent that the system asks to you whether you to be sure of your modification.
/v (been worth): indicate the key
/d (dated): indicate the value of the key
NB: It is necessary to start again the machine for the system takes into account the modification.

NB2: If you carry out this order again, then after the restarting, you will have " twice; ; C:\Lotus\Notes " in your path!

Register base

The variable %PATH% is defined in register base, with other variables of environment defined by the SMSS.exe (administrative of session), very exactly it is value PATH in HKEY_Local_Machine \ SYSTEM \ CurrentControlSet \ Control \ Session Manager \ Environment

See too

Related articles

References

Random links:Symphony n° 5 of Mahler | The Community of communes of the Valley of the Head | Station Micrometer caliper (Tram of Bordeaux) | Poison neural | Arabia Terra | Alexios_IV_Angelos