9

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.

1
  • 2
    Restore from backup. :D
    – RonJohn
    Mar 19 at 17:41

4 Answers 4

15

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 ~/
0
6

There's a default bashrc file you can restore:

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

2
  • Note that the final slash can be omitted - just use a bare tilde. Mar 19 at 13:51
  • @DennisWilliamson Thanks, didn't occur to me as one generally sees ~/ with copy / move actions. Kinda obvious when one thinks about it for two seconds :-) Mar 19 at 14:20
4

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
4
  • Why cat instead of cp? Mar 19 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. Mar 19 at 13:58
  • @DennisWilliamson file ownership?
    – RonJohn
    Mar 19 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. Mar 19 at 18:56
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.