chattrコマンドを利用すれば、ファイルを誤って削除してしまう対策の1つになるだろう。
このコマンドは、ext2ファイルシステム上のファイル属性を変更するものであり、例えば「/var/www/html/」ディレクトリ下すべて(-R)に対して有効にさせたい場合には、次のように指定すればよい。
# chattr -R +i /var/www/html/ |
これによりroot権限でも削除ができなくなる。
# rm /var/www/html/index.html rm: remove write-protected file `index.html'? y rm: cannot unlink `index.html': Operation not permitted |
Copyright © ITmedia, Inc. All Rights Reserved.