[NTLUG:Discuss] PATH variable for beginners

Carl Haddick sysmail at glade.net
Mon Feb 19 20:15:21 CST 2007


On Mon, Feb 19, 2007 at 05:29:46PM -0800, william jones wrote:
> Someone asked me a question about working with the PATH environment variable in the February Beginner Session.  I had not used it in a long time, and did not wish to give outdated misinformation.  After checking a few Linux systems at home, I have answers.
> 
> To add a new directory: PATH=$PATH:path_to_new_directory.  Remember, PATH is the environment variable, $PATH is the address of the variable. Don't forget the colons.
> I added a work directory to my HOME directory.  The new path is added with PATH=$PATH:~/work
> Checked $PATH before the change.  It has several directories separated by colons, a space, then the statement No such file or directory.  Do not worry about this.  Linux will do the right thing with the new addition.  The statement will still be at the end of the PATH environment variable.
> 

Hmmm... Your path variable should just be a list of colon separated
fields - echo $PATH should not show a 'no such' message.

Also, remember to export the new PATH variable if you want it included
in the environment of programs you run.

Apologies for lurking more than contributing, I'll try to do better! :-)

Carl
> If done on the command line, this addition to PATH will disappear when Linux is rebooted.  To save it, the change must be in a file.  The file name varies from distribution to distribution.  in the HOME directory it might be .bash_init, .bashrc or .profile. Check the various bash and profile files.  One will usually tell the user where PATH changes should be made.  If that fails, pick one and give it a try.  /etc has other files that will save the change for the whole system.  Be careful here.  A blunder by user root could bring down the whole system.
> 
> It is possible to remove a directory from PATH, but that is a subject for another class.
> 
> William L. Jones
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss




More information about the Discuss mailing list