Unix: Getting PATH to export to "Stick"

When setting up the export path on Unix, for example:

export PATH=$PATH: $EC2_HOME/bin 

If I close the terminal and open it to continue working, I must complete all the steps again, setting the paths each time. I am wondering how I can set the path and make it stick, so my system knows where to find everything the next time I open the terminal, but I wonโ€™t do it again and again. Thanks!

+6
unix shell terminal export path
source share
6 answers

Open ~/.bashrc. This file is loaded every time you start a new shell (if you use Bash, that is most people). If you use a different shell, the file may have a different name, for example ~/.shrc .

Add the line you need at the bottom of the file:

 export PATH=$PATH:$EC2_HOME/bi 

Other information collapsed from another place in the stream:

There are several places to place this, depending on your shell and your needs. All these files are in your home directory:

For Bash:

 .bashrc (executed when you shart a shell) 

OR

 .bash_profile (executed when you log in) 

For csh and tcsh:

 .cshrc 

For sh and ksh:

 .profile 
+15
source share

Add it to your .cshrc file (for csh and tcsh), the. Profile file (for sh and ksh) or the .bash_profile file (for bash)

+2
source share

You need to find your profile file and put this line there. Suppose you use bash, the profile files -.bashrc and .bash_profile are found in ~. These files will differ depending on the shell used.

+1
source share

You must put these commands in one of the "autostart" files of your shell.

For bash, this will be .bashrc in your home directory (create it if necessary)

+1
source share

add it to your .bashrc or other .bash startup file.

0
source share

... and for ksh edit .profile .

0
source share

All Articles