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.

1
  • BTW, in case you didn't know, you can set -o noclobber to prevent mistakes like these
    – gardenhead
    Aug 10, 2017 at 2:53

1 Answer 1

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.

1
  • 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 9, 2017 at 23:28