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.

0

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
7

There's a default bashrc file you can restore:

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

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .