I have 2 Asus Zenbook laptops running Ubuntu 20.04.3LTS (my current laptop and I kept my old laptop as an emergency backup system as I can't be without a laptop). I very rarely use the old one, but I run sudo ap-get update and sudo apt-get upgrade every 3-4 weeks.

When I last opened it a couple of days ago, I got an error when I opened the terminal:

bash: /home/will/.bashrc: line 100: unexpected EOF while looking for 
matching `)'
bash: /home/will/.bashrc: line 121: syntax error: unexpected end of file  

... although it seems to work fine for everything I've tried to do in the terminal.

As is so often the case, there's nothing obvious in the lines mentioned in the error that is the cause - I've had a quick look through and can't find anything I've changed anywhere else in the file that might cause it. Whilst I could probably hunt it down eventually, it's probably easier to replace the file.

My question is - as I have a second similar laptop running an identical version of Ubuntu, is there any reason not just to copy the functioning .bashrc from the newer laptop to replace the damaged one on my old laptop? I could presumably instead replace with the original version from a live USB (there are some posts on this site suggesting indirectly that that is possible), but it occurred to me that some of the aliases I created (and therefore in the .bashrc on my newer laptop) would be useful to have on the old laptop.

If this is possible, please also say if you're aware of any circumstances when it would not be a good idea. Presumably not sensible between different releases of Ubuntu? This isn't relevant to my situation, but (out of interest) I assume it wouldn't matter if the hardware is very different (eg laptop vs desktop)?

Edit: in response to the comments: it is a self contained file. The only modifications I have (knowingly) made are to add some aliases (to sync data on my encrypted partition with an external keypad encrypted drive). I’ve obviously had a look at the aliases to check I didn’t make a simple mistake but can’t find anything obvious.

  • It looks like there is an unmatched ( on line 100 and possibly an invisible whitespace or special character on line 121. In any case, replacing the file should be an easy fix (see my answer below).
    – mchid
    Nov 16, 2021 at 21:12
  • It's strange that this error just started happening, isn't it? Nov 16, 2021 at 21:42
  • It is strange ... though it might have been there for a while - it's not that obvious if you're not expecting something - I am pretty sure it'll be human error and I've done something funny to the file whilst editing it.
    – Will
    Nov 16, 2021 at 21:59
  • 1
    diff -y -W130 ~/.bashrc /etc/skel/.bashrc | cat -n is a good start
    – user986805
    Nov 17, 2021 at 3:31
  • 1
    @muru - thanks. Yes, it’s self contained. The only modifications I’ve knowingly made are to add aliases to run a synchronisation between the laptop and external drive using rsync. I’ve edited the question with this information.
    – Will
    Nov 17, 2021 at 8:46

3 Answers 3


I don't think there is any reason not to copy and replace the old .bashrc file with the new unless you have a large amount of custom configurations in the file.

The new .bashrc file will be a good, perfectly functioning replacement, assuming there are no user specific custom configurations in the new file.

Just to be safe, it's always best to make a backup of the old file.


The error could be fixed by inspecting your current .bashrc file. However, if you did not do extensive customizations, the safest way, rather than copying a file from somewhere else, will be to reset your current .bashrc to the system default one:

cp /etc/skel/.bashrc ~
  • Useful answer ... gave me the confidence to do the copy from one computer to another knowing I could restore to default if it went wrong.
    – Will
    Nov 22, 2021 at 22:12
  • thanks, have already upvoted both answers and accepted one.
    – Will
    Nov 23, 2021 at 9:48

Thanks to both the answers above - just to confirm I tried it from one laptop to another and it was absolutely fine, and resolved the errors.

I didn't bother making a backup of the old file as it was corrupted anyway, and I knew (thanks to @vanadium answer) how to restore from the system default if it went wrong. For me it was quite useful to be able to do this as it preserved my aliases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.