34

I am a new user of Linux, just switched from Windows. I installed ActiveTcl-8.5 in /opt/ActiveTcl-8.5/, now I want to add its bin directory to the UNIX path.

I have read a number of articles from the net and got confused about which file to modify. My /home/tofayel directory contains .bashrc, .bash_logout, .bash_history, and .profile; but not .bash_login and .bash_profile.

Where do I add the extra lines to add /opt/ActiveTcl-8.5/bin to PATH?

Palec
  • 11,499
  • 7
  • 57
  • 127
Tofayel Ahmed
  • 345
  • 1
  • 3
  • 5
  • You probably want to put it in .bashrc. Have a look at this answer for an explanation about the different files - http://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment – arunkumar Sep 09 '11 at 11:27

3 Answers3

75

The file .bashrc is read when you start an interactive shell. This is the file that you should update. E.g:

export PATH=$PATH:/opt/ActiveTcl-8.5/bin

Restart the shell for the changes to take effect or source it, i.e.:

source .bashrc
Fredrik Pihl
  • 42,950
  • 7
  • 81
  • 128
  • Surely your shell will already have performed the `export`; no need to do it again. – tripleee Mar 25 '16 at 10:28
  • *[How can I correctly add a path to PATH?](https://unix.stackexchange.com/questions/26047)* says *"You should not define environment variables in ~/.bashrc"* – Peter Mortensen Dec 05 '19 at 23:23
10

Actually I would advocate .profile if you need it to work from scripts, and in particular, scripts run by /bin/sh instead of Bash. If this is just for your own private interactive use, .bashrc is fine, though.

tripleee
  • 158,107
  • 27
  • 234
  • 292
  • @Fredrik Pihi , @reader_1000 : I opened the `.profile` file and found that it imports `.bashrc` file. Can you shed some light on this? – Kishor Pawar Jun 18 '15 at 06:02
  • That's not a sane arrangement. Maybe post a separate question, maybe on https://superuser.com/ as this is definitely moving away from programming-related. – tripleee Jun 18 '15 at 07:22
9

you can set it in .bashrc

PATH=$PATH:/opt/ActiveTcl-8.5/bin;export PATH;
reader_1000
  • 2,413
  • 16
  • 15
  • 1
    To clarify what reader_1000 said: open .bashrc add to the end of this file these 2 lines: (PATH=$PATH:/opt/ActiveTcl-8.5/bin; export PATH;) then run command "source .bashrc" to load your new configuration. – Dung Oct 25 '16 at 05:25
  • *[How can I correctly add a path to PATH?](https://unix.stackexchange.com/questions/26047)* says *"You should not define environment variables in ~/.bashrc"* – Peter Mortensen Dec 05 '19 at 23:24