Skip to content

Instantly share code, notes, and snippets.

@mwdiers
Last active August 16, 2017 18:28
Show Gist options
  • Save mwdiers/9c389cad804fcee731f4a9bdca8911f4 to your computer and use it in GitHub Desktop.
Save mwdiers/9c389cad804fcee731f4a9bdca8911f4 to your computer and use it in GitHub Desktop.
chattr +i on ext4
$ mount | grep " / "
/dev/sda on / type ext4 (rw,noatime,errors=remount-ro,data=ordered,jqfmt=vfsv0,usrjquota=quota.user,grpjquota=quota.group)
$ touch dont_touch_me
$ chmod 000 dont_touch_me
$ sudo chown root:root dont_touch_me
$ sudo chattr +i dont_touch_me
$ ls -l dont_touch_me
---------- 1 root root 0 Aug 16 14:20 dont_touch_me
$ rm dont_touch_me
rm: cannot remove ‘dont_touch_me’: Operation not permitted
$ sudo rm dont_touch_me
rm: cannot remove ‘dont_touch_me’: Operation not permitted
$ sudo chattr -i dont_touch_me
$ rm dont_touch_me
rm: remove write-protected regular empty file dont_touch_me’? y
$ ls -l dont_touch_me
ls: cannot access dont_touch_me: No such file or directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment