12

I accidentally changed all the contents of the .bashrc file and I haven't scripted it yet so there's no problem for now. I added little scripts to it (just a few alias), so I can write them again one by one.

How can I restore my .bashrc file with the default settings?

I use Linux Mint.

Cyrus
  • 12,059
  • 3
  • 29
  • 53
Ash
  • 135
  • 5

4 Answers4

12

There exist backup copies of .bashrc, .profile etc. in /etc/skel/. So one could replace a corrupt .bashrc simply by overwitting from there.

How do I restore .bashrc to its default?

cp /etc/skel/.bashrc ~/
Gilles Quénot
  • 31,569
  • 7
  • 64
  • 82
Z0OM
  • 1
  • 4
  • 24
  • 56
7

There's a default bashrc file you can restore:

cp /etc/skel/.bashrc ~ (equivalent of cp /etc/skel/.bashrc /home/<user>)

Peregrino69
  • 2,337
  • 1
  • 15
  • 22
5

The original file that is used when every home directory is created is located in:

/etc/skel/.bashrc

The easiest way:

cat /etc/skel/.bashrc > ~/.bashrc
Nasir Riley
  • 10,665
  • 2
  • 18
  • 27
  • Why `cat` instead of `cp`? – Dennis Williamson Mar 19 '23 at 13:51
  • @DennisWilliamson It doesn't matter. If one want's to copy the file, then that works as well. Using `cat` and `>` to redirect the output the `~/.bashrc` does the exact same thing. It's just the first thing that came to mind. One could ask the inverse for the other method but the same would be true. – Nasir Riley Mar 19 '23 at 13:58
  • @DennisWilliamson file ownership? – RonJohn Mar 19 '23 at 17:41
  • @RonJohn Whether a file or directory,the ownership of data will remain the same with either method. One of the ways that it wouldn't is with `rsync` and even with that, there are switches that can be used to prevent it. – Nasir Riley Mar 19 '23 at 18:56
4

To all of the answers that say /etc/skel/.bashrc -

(and similarly when /etc/skel/.bashrc is not the final answer

eg when an IT department administering engineering workstations makes slightly different changes depending on role such as RTL table designer or verification engineer

  • approaches such as create a new account, and snarf its .bashrc and other default files)

Add "VERSION CONTROL YOUR HOME DIRECTORY", or at least your rc files.

If you make any significant changes to them.

Z0OM
  • 1
  • 4
  • 24
  • 56
Krazy Glew
  • 161
  • 3