How To Prevent Deleting Files Accidentally? – POFTUT

How To Prevent Deleting Files Accidentally?

Every system admin horror is deleting files accidentally especially important and not backup ed configuration files. Here is how can we recover deleted files from Linux systems which is next situation if we skipped this step.

Ask Before Deleting Files

rm is defacto tool to remove files from Linux system. We can setup a mechanism to ask before deleting files with simple alias setup like below.

This will add new alias for rm command with -i  option.

Login and Use Less Privileged User /Do Not Use Root Always

Using root user makes system administrator more powerful and less problematic but as you guess power without control will create problems. Use less powerful user with sudo capability which is default in Ubuntu.

Change Permissions and Owner User Group

Keep permissions strict so do not give 777 to files as far as it is not needed.

We can change permission like

Add Protected Attribute

Linux provides read only attribute which can be given by root. This attribute will make file read only.

LEARN MORE  Linux Chown Command Tutorial with Examples To Change Ownership Of Files

Leave a Reply

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

Enjoy this blog? Please spread the word :)