Click to See Complete Forum and Search --> : Linux PATH file?
FunkSoulBrother
09-15-2001, 03:11 PM
Maybe this is kind of a silly question, but I've just been curious. There seems to be a lot of commands in Linux that you can execute from the command line. In MS-DOS, any command you could execute directly was in the PATH part of autoexec.bat
My question is simply, is there a Linux equivalent to the PATH? Can you just run any executable from the command line, or are there certain ones for which you must be in their directory to run them?
Just curious, thanks for the help,
Rob
bdg1983
09-15-2001, 03:23 PM
The Bash Config NHF (http://www.linuxnewbie.org/nhf/intel/shells/bashconfig.html) is a good place to start to read about the PATH variable.
echo $PATH will tell you what your current PATH is.
Linux does not search the current working directory for the command unless that directory happens to be defined in your PATH and also root and normal users have of course different paths defined.
To allow all commands to be found no matter what directory you are in, add ./ to your $PATH.
i.e. PATH="/bin:/usr/bin:/scripts:./"
where :./ has been added to the end.
FunkSoulBrother
09-15-2001, 03:54 PM
thanks for the help.. Do you suppose it would take a lot of resources/memory to have the computer ready to accept any command from anywhere by making such an all-encompassing PATH?
bdg1983
09-15-2001, 05:25 PM
Originally posted by FunkSoulBrother:
<STRONG>thanks for the help.. Do you suppose it would take a lot of resources/memory to have the computer ready to accept any command from anywhere by making such an all-encompassing PATH?</STRONG>
I really don't think it would. echo $PATH just has './' as another directory.
Anyone else?
Just a couple more points about executing files and the PATH variable; you can, in a pinch, run the executable from the PWD (the directory you're presently in) by just sticking './' in front of it like so:
./executable_filename
or even
sh executable_filename
The PATH directive really should only include the directories like '/bin:/usr/bin:/usr/local/bin" etc and not allow "." to be in the PATH, it's a security risk. If for example, someone gets into your system, they'll stick a trojan 'ps' or 'ls' in /tmp or another widely used directory. If ".", the PWD, is in your PATH, it might execute the trojan app rather than the appropriate system-wide app available in /bin. This is a big problem, especially if you're 'root' when you do this. All your box will belong to them. You should also make the system-wide PATH as sparse as possible, just keep it basic and add all the custom dirs to your own PATH listed in ~/.bash_profile or ~/.profile. Luck!
I don't think it will take up any noticable resources to have a large PATH stored in your shell, but as I said, try to keep it simple and just use "./executable_file" when you need to do something outside the norm.
[ 15 September 2001: Message edited by: bdl ]