Risks of replacing .bashrc file from one computer to another
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.
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 ~