4

Guys,

is it possible to protect a folder against the command sudo rm -rf

Consider the root a drunk person on a high speed road

Comments
  • 10
    Remove drunk person's account from sudoers
  • 4
    https://man.archlinux.org/man/...

    `chattr +i` makes a file immutable -> can't be changed or deleted

    This only makes sense on static files though and would need to be set on every file you want to protect.

    Though someone with root still can do `chattr -i` (remove immutable flag) on the files and then delete them
  • 6
    So
    a) do what @electrineer said
    b) make backups
    c) make more backups
    d) did I mention backups?
  • 1
    I think the immutable bit should do it
  • 2
    Network mount a folder. It's always annoying when sudo rm doesn't work and I realize that the file is not local.
  • 1
    rm /usr/bin/rm
  • 1
    You could also put the directory elsewhere and bind-mount it read ony

    # sudo mount --read-only --bind /your/current/directory /your/new/mount/point

    # rm -rf /your/new/mount/point

    rm: cannot remove /your/new/mount/point/file1: Read-only file system

    rm: cannot remove /your/new/mount/point/file2: Read-only file system

    ...
  • 0
    @2Fdev2Ftcsh that's only the case with root-squash flag set. Isn't it?
  • 2
    Just remove sudo.
Add Comment