Dave Taylor answers free tech support questions about a wide variety of business and technical topics, including blogging, iphone help, ipod help, AdSense, MySpace, Sony PSP help, Mp3 players, Windows XP, Windows Vista, Linux, SEO, Mac OS X, Facebook, Twitter and LinkedIn.

How do I tweak my PATH?

A reader writes:
"I've got a few of your books and today picked up Wicked Cool Shell Scripts, which I'm very much looking forward to working with.

"Totally greenhorn question, though: I want to keep the scripts in ~/bin and on page 12 you have an italic note saying to edit our PATH variable, but I'm not sure how, and don't see any instructions anywhere else as to how to do this. I would be perfectly happy to have ~/scripts as you suggest but have not been able to create either. Your other book Learning Unix for Mac OS X doesn't appear to show how to do this with BASH. Many thanks in advance."


Dave's Answer: The standard way to alter your PATH is to add a line to your ~/.bash_login, ~/.profile or ~/.login file (depending on which shell you're using). Bash will read either of the first two filenames, but let's use ~/.bash_login for consistency sake.

Open up that file (or create one if you don't have it yet) by using vi, pico, emacs, jove, or whatever else is your favorite editor in Terminal.app. Then append your desired directory to the end of the existing PATH value like so:

export PATH="${PATH}:/Users/joe/bin"
Close that terminal window and open another (File -> New Shell), then type echo $PATH and you should see your specified path appended to the end. Then just make sure you have that directory (you can use mkdir ~/bin to create it if needed).

Now you can drop scripts and programs into that file to your heart's content, and they'll automatically be found when you type in their names to the shell.

Note that there's a slight variation on this that can work too, and that might be more commonly used, as demonstrated by this actual entry in my own ~/.bash_login file:

PATH="${PATH}:/sw/bin:/usr/X11R6/bin:/Users/taylor/bin"; export PATH
Hope that helps clear things up!


Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments
Rather amazingly, there are no comments on this article yet.


I have a lot to say, but ...
Starbucks coffee cup I have a lot to say, and questions of my own for that matter, but most of all I'd like to say thank you for all your efforts on this Web site by buying you a chai!

I do have a comment, now that you mention it!









Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Uniblue: Free Virus Scan


Join Me At:
Aloha Social Media Summit, Oct 2008


Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Join the List!
Join my author info mailing list, where you'll learn about my upcoming books, speaking gigs, and more!


Book Links
© 2002 - 2008 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]