如何将.bashrc文件恢复为ubuntu中的默认设置
时间:2020-03-21 11:46:50 来源:igfitidea点击:
前一天,我偶然发现了一个名为"ubunsys"的高级系统配置应用程序。
在我的Ubuntu虚拟机上测试它时,我试图显示隐藏的启动项目,然后用.bashrc文件搞砸了。
每次打开终端时,它会显示出如下所示的错误消息:
-bash: /home/sk/.bashrc: line 68: syntax error near unexpected token `)' -bash: /home/sk/.bashrc: line 68: `xterm*|rxvt*)'
我只使用此VM仅用于测试目的,因此我可以轻松删除它并在几分钟内创建一个新的。
但是,我不想这样做。
我做了一个快速的网络搜索,并在Askubuntu中遇到了一个可靠的答案,描述了如何将.bashrc恢复到其默认设置。
我跟着它,并在几分钟内修复了这个问题。
如果.bashrc文件因任何原因损坏,则可以简单地将.bashrc文件恢复为ubuntu中的默认设置,如下所述。
恢复.bashrc文件到ubuntu中的默认设置
正如我们可能已经知道的那样,Ubuntu中的/etc/skel /目录中存在.bashrc文件的默认版本。
$ls -al /etc/skel/ total 40 drwxr-xr-x 2 root root 4096 May 10 12:26 . drwxr-xr-x 137 root root 12288 Aug 29 11:46 .. -rw-r--r-- 1 root root 220 Apr 5 2016 .bash_logout -rw-r--r-- 1 root root 3771 Apr 5 2016 .bashrc -rw-r--r-- 1 root root 8980 Apr 16 2016 examples.desktop -rw-r--r-- 1 root root 807 Apr 5 2016 .profile
因此,如果我们有问题.bashrc文件,我们可以轻松地将其恢复到下面的默认设置。
首先,使用命令备份当前的.bashrc文件:
$cp ~/.bashrc ~/.bashrc.bak
然后,将默认版本的.bashrc文件复制到当前版本,如下所示:
$cp /etc/skel/.bashrc ~/
最后,运行以下命令以更新更改。
$source ~/.bashrc
如果我们在不知不觉中删除了.bash_profile或者.bashrc文件,请按照上述步骤将其恢复为默认值。