Why do I need to source bash_profile every time

后端 未结 6 1355
[愿得一人]
[愿得一人] 2021-02-04 01:28

I have installed Hadoop and every time I want to run it, first I have to do this:

source ~/.bash_profile

or it won\'t recognize the command

6条回答
  •  野性不改
    2021-02-04 02:22

    I tried the approved answer. Changing the .zshrc file works for one of my machines. But for the other one, when I run ps -p $$, it is -sh under the command. And I changed both bash and zsh files, neither of them works for me this time.

    So I found this https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html

    it mentioned "When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. "

    so I went to that file /etc/profile and add "source ~/.bashrc" in that file. Then it works since every time a terminal is opened, it runs the command in that /etc/profile file.

提交回复
热议问题