Home FAQ How To Restore .bashrc File To Default Settings In Ubuntu
Restore .bashrc file to default settings

How To Restore .bashrc File To Default Settings In Ubuntu

By sk
1619 Views

The other day I stumbled upon an advanced system configuration application called "Ubunsys". While testing it on my Ubuntu virtual machine, I tried to show hidden startup items and then messed up with the .bashrc file. Every time I open the Terminal, It displayed an error message something like below:

-bash: /home/sk/.bashrc: line 68: syntax error near unexpected token `)'
-bash: /home/sk/.bashrc: line 68: `xterm*|rxvt*)'

I use this VM only for testing purposes, so I could easily delete it and create a new one in couple minutes. But, I don't want to do that. I did a quick web search and came across a reliable answer in AskUbuntu that described how to restore .bashrc to its default settings. I followed it, and fixed the issue within a few minutes. If your .bashrc file is corrupted for any reason, you can simply restore your .bashrc file to default settings in Ubuntu as described below.

Restore .bashrc File To Default Settings In Ubuntu

As you might already know, there is a default version of the .bashrc file in the /etc/skel/ directory in Ubuntu.

$ ls -al /etc/skel/
total 40
drwxr-xr-x 2 root root 4096 Jul 10 12:26 .
drwxr-xr-x 137 root root 12288 Aug 29 11:46 ..
-rw-r--r-- 1 root root 220 Apr 5 2018 .bash_logout
-rw-r--r-- 1 root root 3771 Apr 5 2018 .bashrc
-rw-r--r-- 1 root root 8980 Apr 16 2018 examples.desktop
-rw-r--r-- 1 root root 807 Apr 5 2018 .profile

So if you have problems with .bashrc file, you can easily restore it to its default settings like below.

First, backup your current .bashrc file using command:

$ cp ~/.bashrc ~/.bashrc.bak

Then, copy the default version of .bashrc file to your current version like below:

$ cp /etc/skel/.bashrc ~/

Finally, run the following command to update the changes.

$ source ~/.bashrc

If you unknowingly messed up your .bash_profile or .bashrc files, follow the above steps to restore them to the default value. I tested this in Ubuntu 16.04 LTS, and worked fine. I hope It will probably work on other Ubuntu versions and derivatives.

Reference:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

10 comments

Yessi July 5, 2018 - 4:23 am

This saves my life. Thanks!
Gracias =)

Reply
janeen October 24, 2019 - 8:13 am

Hello this is not working for me is there any other solution.

Reply
janeen October 24, 2019 - 8:18 am

this is the error I am getting
C:\Users\user1>bash
-bash: /home/user1/.profile: line 28: syntax error near unexpected token `(‘

Reply
sk October 24, 2019 - 11:52 am

C:\Users\user1>bash?? What is your OS version? Looks like you’re trying it on Windows PC.

Reply
janeen October 24, 2019 - 11:54 am

yes I am trying in the bash system

Reply
sk October 24, 2019 - 12:49 pm

What do you mean by bash system? It is a shell. There is no such prompt like yours (C:\Users\user1>bash) in Linux systems. I think you’re trying to run bash from Windows command line. I don’t have much knowledge about Windows OS.

Reply
Raghavan alias Saravanan Muthu February 16, 2020 - 2:17 pm

Hey, that is a very good post. So far I have not faced any issues and hence was not in any need to restore the .bashrc file, but will bookmark this for any future purposes 🙂

Reply
Tatiana March 27, 2020 - 12:07 pm

It saved my life.

Reply
Sha September 17, 2020 - 4:44 pm

May the programming gods smile brightly on you!

Thanks! This saved me hours of headaches.

Reply
sk September 17, 2020 - 6:49 pm

Glad I could help. You’re very welcome!

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More