Linux – Set your PATH Variable using set or export command


The syntax for setting path under UNIX / Linux dependent on which shell you are using.

BASH / SH shell uses following syntax:

export PATH=$PATH:/path/to/dir1:/path/to/dir2

For tcsh or csh, shell enter:

set PATH = ($PATH /path/to/dir1 /path/to/dir2)

You can type above command at the terminal or add it to your .bashrc (for BASH/sh shell) or .cshrc (for chs / tcsh shell) so that PATH can be set each time you login into box.

For example add /usr/local/bin to your path under BASH, enter:
export PATH=$PATH:/usr/local/bin

Or add as follows to your .bashrc file:

echo 'export PATH=$PATH:/usr/local/bin' >> ~/.bashrc

If you are using CSH / TCSH, enter:

echo 'set PATH = ($PATH /usr/local/bin /scripts/admin)' >> ~/.cshrc

To display path settings, enter:

$ echo $PATH

Leave a Reply

Your email address will not be published. Required fields are marked *