Create BACKUP of Linux Files Before Editing

Before editing any important file, the best practice is to create a backup of it.

The extensions “.bak”, “.sav”, “.old”, and “.orig” are all popular ways of indicating a backup file.

So, create the simplest backup using .bak:

cp .bashrc .bashrc.bak

Now, if we run ls, we can see that .bashrc.bak appears slightly dimmed:

If you need to, you can restore it the same way:

cp .bashrc.bak .bashrc

.bak has:

  • No special permissions
  • No special system behavior
  • No automatic restore feature

It’s just a normal file with a name that tells humans: “this is a backup.”

Leave a Reply

Your email address will not be published. Required fields are marked *.