How do you add any current directory './' to the search path for executables in Linux?
相关问题
- Is shmid returned by shmget() unique across proces
- How to access the camera from my Windows Phone 8 a
- how to get running process information in java?
- Highlight parent path to the root
- Error building gcc 4.8.3 from source: libstdc++.so
works with bash 4.3.48
I know this is an old answer, but if anyone else stumbles across this question via Google like I did, here's a more detailed explanation.
If you want to make it so that search path contains the value of
pwd
at the time you set the search path, do:So, if
pwd
is/home/me/tmp
, PATH will be set to$PATH:/home/me/tmp
However, If you want it so that whatever your present working directory is at the time you execute a command (ex; the value of
pwd
at any given time is in the search path), do:So, if
pwd
is/home/me/tmp
, PATH will be set to$PATH:.
. If your present working directory contains a script calledfoo
, then it would be fount in your PATH. If you change directories to one that does not containfoo
, "foo" will not be found in the PATH any more.You should note that having your present working directory in your PATH is a potential security risk, however.
This is an old question, but I thought I'd add to it for those using the CSH or TCSH.
Adding the following to your .cshrc or .tcshrc will add the current directory to the environment path variable.
If you want to permanently add the directory you're currently in to the PATH variable you can use
which will expand
$(pwd)
to the string literal of your current directory and append the quoted line to your bashrc. Note the\
in\$PATH
is needed to escape the expansion of$PATH
to its current value.Um...that didn't work for me. I would do
export PATH=$(pwd):$PATH
The command previously posted literally just adds the dot.
For the current directory, you can just use a zero-length (null) directory name. You can use an initial or trailing colon, or a double colon. This is from the bash manpage,
man bash
: