Thursday, May 14, 2009

Linux Path - Display and Modify

I'm in the process of learning Linux, which I really like so far. One thing I found recently was how to modify the PATH variable in Linux, like I do with Windows.

To display your current path variable, type "echo $PATH" and press enter

To modify your PATH environment variable for your current session, you use the EXPORT command (not sure why it's named that) to do this. Suppose you wanted to add the directory "/sbin" to your path for the current session, you would type "EXPORT PATH=$PATH:/sbin"

To make a permanent change to your PATH variable for every time you open a shell, you need to mdofiy the hidden file that automatically executed every time you start the shell. This file is named ".bashrc" if your using the bash shell, and you would add "EXPORT PATH=$PATH:/sbin" to the end of the file. Now, every time you open a new shell, that directory will be included in your path.

Thanks to Sitepoint for a great book, "Run Your Own Web Server Using Linux & Apache"

No comments: