How To Prevent Deleting Files Accidentially
Every system admin horror is deleting files accidentally especially important and not backuped configuration files. Here is how can we recover deleted files from Linux systems which is next situation if we skipped this step. Ok let’s start steps to take
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.
$ echo 'alias rm=rm -i' >> .bashrc
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 powerfull and less problematic but as you guess power without control will create problems. Use less powerfull user with sudo capabilty 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
$ chmod 640 config.cfg
Add Protected Attribute
Linux provides read only attribute which can be given by root. This attribute will make file undeleteable.
$ sudo chattr +i pnggrad8rgb.png