【问题标题】:I removed a path from .profile and .bashrc but still present in $PATH [closed]我从 .profile 和 .bashrc 中删除了一个路径,但仍然存在于 $PATH [关闭]
【发布时间】:2016-06-27 18:30:22
【问题描述】:

我从 .profile 和 .bashrc 中删除了我之前在 $PATH 变量中添加的路径,但它仍然存在于后者中。我真的不明白为什么。有什么帮助吗?

谢谢

【问题讨论】:

  • 快速注销/重启,然后响应。
  • @Am_I_Helpful 当我输入“logout”时出现错误:bash:logout is not a connexion shell: use exit,当我使用 exit 时重定向到“sh”
  • 我的意思是系统级注销,而不仅仅是退出 shell。你有哪个 linux/unix 发行版?
  • @Am_I_Helpful 好的,我重新启动了 Ubuntu,它可以工作了,谢谢!但是为什么我必须重新启动ubuntu,我认为重新启动shell就足够了......
  • @mric750 - 因为 PATH 是一个环境变量,它是全局级别配置的一部分。因此,您需要执行用户注销或重新启动才能使更改生效!

标签: linux bash ubuntu path environment-variables


【解决方案1】:

这可以使用source 命令来完成。

source ~/.profile
source ~/.bashrc

现在检查 $PATH。

echo $PATH

删除的路径不会显示出来。

【讨论】:

  • 如果我的/etc/profile 设置PATH~/.profile~/.bashrc 仅添加到它,这将不起作用。如果是这种情况,则需要一些技巧,例如 this answer 中的演示。
猜你喜欢
  • 2012-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多