LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   adding folder to user accounts PATH variable (http://www.linuxquestions.org/questions/linux-newbie-8/adding-folder-to-user-accounts-path-variable-4175452876/)

TechJay 03-05-2013 09:43 PM

adding folder to user accounts PATH variable
 
Hello all, i need a little help.

This is what ive done thus far:
Created a folder in my home directory called 'data'.
Changed the group owner of data to 'users' group.
Set permission SGID on the directory.

Now i need to:
Add the 'data' folder to my user accounts PATH variable & make sure it is in the users PATH each time i log in.

Problem:
I do not fully understand path variable but have a general idea on how it works, and im not sure which file will run each time i log in.. any help would be appreciated! thanks

suicidaleggroll 03-05-2013 09:52 PM

What shell are you using?
Code:

echo $SHELL
Bash is generally the default, in which case the PATH can usually be modified in one of two places:
~/.bashrc
or
~/.bash_profile

~/.bashrc is sourced every time a terminal is opened
~/.bash_profile is sourced once when you first log in

Therefore, .bashrc is generally used for aliases or things that can change between opening terminals on a given login session, while .bash_profile is used for environment variables that are only set once when you first log in. I almost always modify the PATH in .bash_profile rather than .bashrc, because if you append to your PATH in .bashrc, every time you open a terminal you'll append more and more onto your PATH, whereas with .bash_profile your PATH is just set once and then left alone.

To add $HOME/data to your PATH, you would simply add something like the following into one of your login scripts (.bashrc, .bash_profile, etc):
Code:

export PATH=${PATH}:$HOME/data
If you "echo $PATH" before and after the above command, you'll see that your new directory has been added.

TechJay 03-05-2013 09:56 PM

fedora 13 Goddard

and thanks for the help

shivaa 03-05-2013 10:32 PM

For csh or tcsh shell:
Code:

setenv PATH $HOME/data:$PATH
To add it permanantly:
Code:

echo "setenv PATH $HOME/data:$PATH" >> ~/.cshrc
For sh/bash, as said above, you can use export cmd and add the same in your '~/.bashrc' file.

TechJay 03-05-2013 10:37 PM

Very helpful thanks !

@ shiva: Thats a little beasty for my lol That step just skips me having to open it with editor and adding perm ?

suicidaleggroll 03-05-2013 10:39 PM

Quote:

Originally Posted by TechJay (Post 4905608)
Very helpful thanks !

@ shiva: Thats a little beasty for my lol That step just skips me having to open it with editor and adding perm ?

Only if you're using the csh/tcsh shell. You haven't posted the output of my original question yet:

Quote:

What shell are you using?
Code:

echo $SHELL

Without knowing what shell you're using, it's impossible for us to tell you what file you need to modify.

TechJay 03-05-2013 11:03 PM

re installing.. Ill check in justa minute

TechJay 03-06-2013 12:38 AM

bin bash

shivaa 03-06-2013 12:50 AM

Quote:

Originally Posted by TechJay (Post 4905655)
bin bash

In that case, follow what suicidaleggroll has suggested:
Code:

~$ export PATH=${PATH}:$HOME/data
To make it permanant:
Code:

~$ echo "export PATH=${PATH}:$HOME/data" >> ~/.bashrc


All times are GMT -5. The time now is 02:27 AM.