2

I'm working on a linux client and I need to add my home directory path to $PATH but I was unable to do that. I tried to find .bash_profile file and also .bashrc file but both are missing. Please let me know how to achieve this.

4 Answers4

2

Here is a good article on understanding configuration files: http://www.ibm.com/developerworks/linux/library/l-config/index.html#4

The point is - like everyone else says:

  • If it does not exist - create it.
  • If process does not recognize it - restart the process.
  • If it doesn't work - read the manual, may be that config file are not optional or you putted it into a wrong place (for example root user uses different configs due to home dir of root).
JackLeo
  • 258
  • 2
  • 11
1

If a .bashrc file doesn't exist, create one! Try adding one with this in it:

export PATH=$PATH:$HOME
  • Will it affect other users if I do. I want the $PATH name to be modified only for my username. –  May 17 '11 at 05:35
  • If the `.bashrc` file is in *your* home directory, it should affect only you. –  May 17 '11 at 05:36
  • How can I do this inside a perl script? Like if i want the $PATH to be changed only for that script means?? –  May 17 '11 at 06:05
  • @Srikk: Sorry, I'm not familiar enough with Perl to help you with that. You can start a new question if you'd like. –  May 17 '11 at 06:18
  • I created .bash_profile with the above data you mentioned, but when I ran echo $PATH, my directory is not included. what to do? –  May 17 '11 at 06:27
  • @Srikk: I'm not quite sure why that wouldn't be working, but you may want to try adding a `.bash_login` file as well with this in it: `. ~/.bashrc`. –  May 18 '11 at 06:23
0

If those files don't exist, you can simply create them.

Bill Lynch
  • 261
  • 1
  • 6
0

If .bash_profile doesn't exist in your home directory, you can always create it. To accomplish the goal of adding your home directory to the $PATH environment variable add a line similar to the following:

export PATH=$PATH:$HOME
Asaph
  • 140
  • 5