LinuxQuestions.org
Visit Jeremy's Blog.
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 10-16-2010, 04:19 PM   #1
jimmydean
LQ Newbie
 
Registered: Oct 2010
Posts: 3

Rep: Reputation: 0
Question Change PATH variable


I want to add my current working directory to the PATH variable and make it permanant in my .bash_profile so I can run my testscript without using the ./ charactors
can this be done?
 
Old 10-16-2010, 04:26 PM   #2
johnshen64
LQ Newbie
 
Registered: Jun 2010
Posts: 29

Rep: Reputation: 5
yes you can but it is not recommended, as it is a security risk, because if you are in some world-writable directory someone could plan a trojan program, say, ls. it is better to invoke programs in your current directory explicitly using ./

if you really wants to do it, here it is.

export PATH=${PATH}:.
 
Old 10-16-2010, 04:35 PM   #3
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
That is only temporary of course.

To make it permanent as he wanted, he needs to add his directory to the PATH variable in /etc/bashrc or /etc/profile.

Or he can add the code you gave him to his own hidden .bashrc file in his home directory.

Last edited by dv502; 10-16-2010 at 04:37 PM.
 
Old 10-16-2010, 04:41 PM   #4
jimmydean
LQ Newbie
 
Registered: Oct 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks John
It is only for a linux class and I have put the wrong path in there and it wont let me do anything now.
I am only a user so I can't get back in to change it back, so I have to wait till the administrator fixes it again.
thanks JIm
 
Old 10-16-2010, 05:24 PM   #5
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
@ jimmydean

When you are able to log back into the system just remove the bad PATH you setup or better yet, put a hash mark # in front of the PATH statement. This will cause the shell to ignore that line.

Then add a line like this to your .bashrc or .bash_profile file

export PATH=$PATH:$HOME/bin

In this example the bin folder is where all your scripts are located. You can replace bin with any directory of your choice.

Last edited by dv502; 10-16-2010 at 05:44 PM.
 
  


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
Add path to $PATH variable alaios SUSE / openSUSE 2 04-19-2009 08:41 AM
bash script path issue - how to pass a path as a string to a variable PiNPOiNT Programming 5 04-17-2009 05:48 PM
how to change $PATH enviroment variable bglnelissen Linux - Software 2 11-03-2004 06:55 AM
change PATH variable in Suse 9.0 jesus_edu Linux - Newbie 5 03-29-2004 09:33 AM
I cannot change my PATH$ variable KptnKrill Linux - Newbie 6 08-17-2003 03:03 PM

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

All times are GMT -5. The time now is 10:00 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