简体   繁体   中英

How can I add the current directory to the search path in UNIX?

I cannot fix the command not found errors in UNIX bash. I need to add the current directory to my search path. However, I searched in google but I cannot find anything which tells me the direct solution (since I am in the beginner level and it is hard to understand)

when I write to terminal pwd , it says

/Users/macbook

when I write echo $PATH , it says

/Users/macbook/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/opt/X11/bin:/Users/macbook/OPT/BIN:/Users/macbook/opt/bin

How can I add the current directory to my search path? Thank you for any help!

在您的终端上尝试一下,它应该可以工作。

PATH=$PATH:$(pwd)

If you want bash to always search the current directory first for the command, not matter in which directory you are currently in, you can add "." to your PATH variable. For that, edit the file .bash_profile or .profile file in your home directory (first one present) and add the line:

PATH=.:$PATH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM