How to prevent Linux system, a critical file is modified

In a Linux environment, some important configuration file is not allowed any person (including root) to make changes. In order to prevent accidentally, accidental deletion or modification operations may be required to set "bit can not be modified (the immutable)" of the file permissions. We have / etc / fstab file, for example, the file records important hard disk partition information appears as follows:

[root@localhost ~]# cat /etc/fstab

#

/etc/fstab

Created by anaconda on Sat Jun 8 16:22:16 2013

#

Accessible filesystems, by reference, are maintained under '/dev/disk'

See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#
UUID=3adeaadc-36c6-4b3b-bf99-aca7e6dfc15f / ext4 defaults 1 1
UUID=6a44e4ad-56b4-4877-8da4-e0bc21979b16 /boot ext4 defaults 1 2
UUID=e9ad5c94-6eee-4927-998a-9ce6024be355 /webserver ext4 defaults 1 2
UUID=5879d097-eadb-4ad2-bbb1-1b3323e86192 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0

We use the chattr command protection, command is as follows:

[root@localhost ~]# chattr +i /etc/fstab

If you need to modify the file using the following command:

[root@localhost ~]# chattr -i /etc/fstab

Guess you like

Origin blog.51cto.com/14662442/2468179