我需要将其放入export PATH=$PATH:/opt/lampp/bin
我的~/.bash_profile
文件中,以便命令行中的 mysql 在我的系统上运行。请检查mysql 命令行不工作了解更多详细信息。
我正在 Fedora 系统上工作并以 root 用户身份登录。
如果我跑步locate .bash_profile
,我会得到这些:-
/etc/skel/.bash_profile
/home/sam/.bash_profile
/home/sohil/.bash_profile
/home/windows/.bash_profile
/root/.bash_profile
因此,我修改了该/root/.bash_profile
文件如下:-
从
PATH=$PATH:$HOME/bin
export PATH
到
PATH=$PATH:/opt/lampp/bin
export PATH
但是,更改仍然没有生效——打开一个新的控制台并mysql
再次运行bash: mysql: command not found
。
但是,在控制台中运行export PATH=$PATH:/opt/lampp/bin
可以使其在该会话中工作。因此,我对文件的操作有误.bash_profile
。可能是编辑了错误的文件或编辑方式不正确。
更新
在进行上述编辑之前,我也尝试过在export PATH=$PATH:/opt/lampp/bin
最后添加如下内容:-
从
PATH=$PATH:$HOME/bin
export PATH
到
PATH=$PATH:$HOME/bin
export PATH=$PATH:/opt/lampp/bin
但它不起作用。我错过了什么?
谢谢,
Sandeepan
答案1
.bash_profile
只应由登录 shell 运行一次。 .bashrc
是针对每个孩子运行的文件。
尝试注销并再次登录,然后查看您的.bash_profile
更改是否被应用。
仅就章节和诗句而言,这是来自 bash 的手册页:
When bash is invoked as an interactive login shell, or as a non-inter‐
active shell with the --login option, it first reads and executes com‐
mands from the file /etc/profile, if that file exists. After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the first one that
exists and is readable. The --noprofile option may be used when the
shell is started to inhibit this behavior.
When a login shell exits, bash reads and executes commands from the
file ~/.bash_logout, if it exists.
When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc, if that file exists. This
may be inhibited by using the --norc option. The --rcfile file option
will force bash to read and execute commands from file instead of
~/.bashrc.
答案2
如果您不想注销以应用更改,
# source ~/.bash_profile
应应用您的更改。