MilesWeb
MilesWeb Hosting Forum

Please login or register.

Login with username, password and session length

 

News:

SMF - Just Installed!


Author Topic: How to stop accidentally delete of files and folder in Linux ?  (Read 9235 times)

0 Members and 1 Guest are viewing this topic.

Offline Dipak Bhoi

  • MilesWeb Team Member
  • Full Member
  • ***
  • Posts: 208
  • Karma: +5/-0
    • View Profile
    • MilesWeb Internet Services
Hi guys,

In this post I will discuss about command to stop accidentally delete of files and folder in Linux.

chattr command : -

chattr attribute is used to stop accidentally delete of files and folder. You cannot delete the files secured via chattr attribute even though you have full permission over files.

Syntax for chattr command

The operator + causes the selected attributes to be added to the existing attributes of the files; - causes them to be removed; and = causes them to be the only attributes that the files have.

-R

Recursively change attributes of directories and their contents.

-a

A file with the a attribute set can only be open in append mode for writing. Only the superuser can set or clear this attribute.

-i

A file with the i attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file. Only the superuser can set or clear this attribute.

Example :-

To add chattr run below command.

Quote
#chattr +aui /root/impfiles.conf

To remove chattr run command as below.

Quote
#chattr -aui /root/impfiles.conf
Hope this post help you.

Enjoy !!!
MilesWeb.com - 30-Day Money Back
cPanel Web Hosting - cPanel Hosting in India.
Grab a Free SSL for your website.  WordPress Optimized Solution.

MilesWeb Hosting Forum