首页 > 解决方案 > .bashrc 和 .bash_profile 丢失

问题描述

我在 .bash_profile 中添加了一些内容。我通过向 $PATH 添加一些路径搞砸了。注销并重新登录后,我找不到 .bashrc 或 .bash_profile。但是当我回显 $PATH 或在 bashrc 中设置的东西时,它会出现。所以,我尝试从 /etc/skel/ 复制 .​​bashrc 和 .bash_profile。即使在复制和重新启动之后,出于某种原因,我的旧别名和所有内容都是从旧的 .bashrc 中挑选出来的。我完全想删除之前设置的所有内容并创建一个新的 .bashrc 和 .bash_profile。

即使在复制新的 .bashrc 和 .bash_profile 并对它们进行源 ~/.bashrc 并重新启动后,我仍然看到这个来自旧的 .bashrc:

[user@user.x main]$ git branch
/opt/cross/rh-git29/root/usr/bin/git: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory

[user@user.x main]$which git
alias git='/opt/cross/rh-git29/root/usr/bin/git'
    /opt/cross/rh-git29/root/usr/bin/git

此外,现在当我打开 .bashrc 和 .bash_profile 时,它​​会从 /etc/skel 打开复制的文件,但它会在 vim 中附加 //。如果我执行“vim ~/.bashrc”,打开后我会在 vim 窗口中看到 ~//.bashrc。

此外,当我执行“alias -p”时,该 .bashrc 配置文件中的旧别名仍然出现。我使用 unalias 删除了别名,但它仍然会出现。即使我在当前的 .bashrc 中设置了新的 $HOME,我的旧 $HOME 仍然会显示。

如何检查旧 .bashrc 和 .bash_profile 的路径以及为什么会被拾取?我如何完全重置这些配置文件?如何永久删除这些别名 - 尝试在当前 .bashrc 中同时使用 unalias 和设置别名 git="git" 以覆盖,但它在注销后仍会选择旧别名。

标签: linuxbashpath

解决方案


推荐阅读