Linux / Unix: Set your PATH Variable using set or export command

Question. How do I add new path to PATH variable under Linux and UNIX operating system?

Answer. 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

  • 4 Users Found This Useful
Was this answer helpful?

Related Articles

How to install ionCube Loader on Ubuntu

ionCube is a Zend-Engine extension to encode PHP files. To install it on Ubuntu first...

Install Postfix to configure SMTP Server. -- Fedora 16

[root@mail ~]# yum -y install postfix [root@mail ~]# vi /etc/postfix/main.cf #...

Install Dovecot to Configure POP/IMAP Server. -- Fedora 16

[root@mail ~]# yum -y install dovecot [root@mail ~]# vi /etc/dovecot/dovecot.conf # line...

Create SSL Certficates for Mail server - Fedora 16

[root@www ~]# cd /etc/pki/tls/certs [root@www certs]# make server.key umask 77 ; \...

Configure Postfix and Dovecot for SSL - Fedora 16

[1] Create certifcate first. Click here[2] Configure Postfix and Dovecot for SSL [root@www ~]#...