Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

The .bashrc PATH= doesn't seem to work for what I'm doing.

I'm using the TeamTreeHouse console. Forgive me as I believe I've had this question answered before but I thought I might clarify.

I made a text document called blahs, I added the text file in .bashrc to the export path like so, PATH=/home/treehouse/cow/moo/too/zoo/blahs:$PATH

When I run less blahs I get the message no such file or directory. When I use the absolute path above it works.

Am I using PATH incorrectly or is PATH made for something other than text files, as I see my text file has no execute permissions?

Thanks, van

1 Answer

Justin Ellingwood
Justin Ellingwood
12,545 Points

Hi danielwhitten,

I think you are a bit confused about what the PATH variable is used for. Its purpose is to designate the location of applications, not text files. The PATH variable is used as a set of directory locations that contain executable programs.

For instance, the less program you are trying to is likely stored in /bin/less. If the PATH variable did not exist, then every time you wanted to run less, you would have to type the entire absolute path to the executable (/bin/less) instead of just the program name. When you type just the program name, as you do with most commands, the Bash shell looks at the PATH variable for a list of directories. It then searches in each of those directories sequentially for the program you are calling and executes the first match it finds.

In your case, you added a text file to the PATH. The Bash shell can't do anything with that because it is not an executable file. Even if it was an executable, you are calling it as an argument to the less command, so the PATH would not be referenced for that.

If you need easy access to a file that is located in a difficult location, one option would be to create a symbolic link. Think of this as a shortcut file in Windows parlance. You still must be in the same directory as the link you create, but this way, you can keep the file in its proper place and reference it from a location where you're more likely to be spending time in.

For instance, if you want to create a link to the /home/treehouse/cow/moo/too/zoo/blahs file and put it in your home directory (/home/treehouse), you could issue this command:

ln -s /home/treehouse/cow/moo/too/zoo/blahs /home/treehouse/blahs

Now, you should have a link in your home directory called blahs. If you are in your home directory, you can type:

less blahs

And it should show you the content of the /home/treehouse/cow/moo/too/zoo/blahs file.

This is one way of addressing the problem, but doesn't really let you access the file globally by name alone. I can't think of an easy way of doing that off the top of my head.