LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-05-2013, 08:43 PM   #1
TechJay
LQ Newbie
 
Registered: Mar 2013
Location: WV
Distribution: Fedorra Goddard for now
Posts: 27

Rep: Reputation: Disabled
Thumbs up 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

Last edited by TechJay; 03-05-2013 at 08:51 PM.
 
Old 03-05-2013, 08:52 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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.

Last edited by suicidaleggroll; 03-05-2013 at 08:54 PM.
 
1 members found this post helpful.
Old 03-05-2013, 08:56 PM   #3
TechJay
LQ Newbie
 
Registered: Mar 2013
Location: WV
Distribution: Fedorra Goddard for now
Posts: 27

Original Poster
Rep: Reputation: Disabled
fedora 13 Goddard

and thanks for the help
 
Old 03-05-2013, 09:32 PM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
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.
 
1 members found this post helpful.
Old 03-05-2013, 09:37 PM   #5
TechJay
LQ Newbie
 
Registered: Mar 2013
Location: WV
Distribution: Fedorra Goddard for now
Posts: 27

Original Poster
Rep: Reputation: Disabled
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 ?
 
Old 03-05-2013, 09:39 PM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by TechJay View Post
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.
 
1 members found this post helpful.
Old 03-05-2013, 10:03 PM   #7
TechJay
LQ Newbie
 
Registered: Mar 2013
Location: WV
Distribution: Fedorra Goddard for now
Posts: 27

Original Poster
Rep: Reputation: Disabled
re installing.. Ill check in justa minute

Last edited by TechJay; 03-05-2013 at 10:46 PM.
 
Old 03-05-2013, 11:38 PM   #8
TechJay
LQ Newbie
 
Registered: Mar 2013
Location: WV
Distribution: Fedorra Goddard for now
Posts: 27

Original Poster
Rep: Reputation: Disabled
bin bash
 
Old 03-05-2013, 11:50 PM   #9
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by TechJay View Post
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Adding a path variable Taylrl Linux - Newbie 20 06-02-2012 02:08 PM
adding sth. to all users' PATH variable (sudo included) tpresa Linux - Software 2 08-03-2010 03:16 PM
adding user accounts to different domains momoberto Linux - Newbie 1 05-12-2010 07:07 AM
Adding a executable file $PATH Variable ajeet@linux Solaris / OpenSolaris 3 03-18-2010 12:30 PM
Adding JavaVM to PATH variable? Crickit Linux - Software 3 05-06-2003 03:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration