4

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.

Ravexina
  • 55,668
  • 25
  • 164
  • 183

1 Answers1

7

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:

/usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc

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

Ravexina
  • 55,668
  • 25
  • 164
  • 183
  • 4
    A suggestion that would make this answer more useful: first do dpkg -S /etc/bash.bashrc to show which package provides that file, in case it's unknown (in this case it's probably obvious to most people, but for a different file it might not be). – hobbs Aug 09 '17 at 23:28