Command-Line – How to Restore Accidentally Deleted /etc/bash.bashrc Without Reinstalling Ubuntu?

bashbashrccommand line

In a brand new system, I mistakenly deleted /etc/bash.bashrc, by creating and redirecting to it, instead just appending.

How could I restore it without reinstalling the system?

As the experts here know, this is an important file in the system and I need it for proper working of the system as well as aliases.

I tried rebooting assuming it will be recreated but it isn't. In a quick Google search I found nothing (I found many results regarding restoring ~/.bashrc but of course it's different).

How could I restore it fast without copying from another PC?

A same-PC minimal, fast, solution.

Best Answer

Either restore that single file from bash's deb package:

$ apt-get download bash
$ dpkg-deb --fsys-tarfile bash_*.deb > /tmp/bash_pkg.tar
$ tar -Oxf /tmp/bash_pkg.tar ./etc/bash.bashrc | sudo tee /etc/bash.bashrc

Or restore all missing files of bash:

sudo apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall bash

Read more

There is also a file which might be helpful to you:


however I believe that this file is belong to adduser package.