how to make ./ not necessary when executing
hi, when i want to execute a file in the terminal it always makes me type ./ first, is there something i can edit to have it so i don't have to type ./?
|
You can add the current directory to the PATH variable. In ~/.bashrc (or ~/.bash_profile)
Code:
PATH=$PATH:. |
Yes, you just have to include . (the current directory) in the PATH variable. Some distros put . in the PATH for the ordinary users, but never for root.
In ~/.bashrc file, try putting something like this PATH=$PATH:. |
Depending on what shell, terminal, desktop, distribution, etc. you are using, there are a bunch of different places you might add or change an export of the PATH variable.
The most likely (not knowing any the details of your system) is ~/.bashrc Edit that file. Did it already exist? Did it already include a line starting export PATH= If so, you can add .: right after the = If the line wasn't there, you could add export PATH=.:$PATH Quote:
Adding . at the end of PATH rather than the beginning means it would find programs in . only if the same program is not elsewhere in the path. Again, I think that is not the desired behavior (though I understand why some people might want that behavior). |
The files we edit may probably differ from distro to distro. But, I learnt that all environment variables go into .bash_profile and aliases etc go into .bashrc. So, the PATH variable is preferably put in .bash_profile.
Secondly, if I'm right '.' is not necessary to indicate current directory. Just ending the PATH with ':' should do. As, Code:
echo 'PATH=$PATH:' >> .bash_profile |
thanks everybody,
after trying all those suggestions, it appeared to only work in the bashrc file, though i do have a profile file too. but all the different methods worked and i can now compute worry free. but please, do tell, what is a distro? |
Quote:
As to the other thing, I'd rather have the dot at the end of PATH. Precisely for the reason you've stated. The command is looked up in the current directory only if it's not found elsewhere. Somehow it seems right for security reasons and also prevents certain mess when a program compiled by the user accidentally has the name used in the system. |
Quote:
|
now if the command you are wanting to run is
configure , make , make install DO NOT put that folder path into the system path !!!! But if it is a program that you installed , say Gimp ( i build and install it in it's own folder) then DO put it in the system path |
Is it really too much trouble typing ./ before a command?
|
All times are GMT -5. The time now is 07:37 PM. |