Make a file immutable

Nobody, not even root, can change the file until the flag is removed with chattr -i. Good for when something keeps rewriting resolv.conf behind your back.

chattr +i /etc/resolv.conf && lsattr /etc/resolv.conf

tool
linux133 commands
tags
linuxfilesystemsecurity

More linux commands

  • lsattr -R /etc/ 2>/dev/null | grep -v '^\-\-\-\-'

    List files in /etc/ that have non-default attributes.

  • getfacl /srv/shared

    Show POSIX ACL entries: owner, group and extra users.

  • setfacl -m u:alice:rwx /srv/shared

    Give alice full access without changing the group owner.

  • find / -perm /6000 -type f -ls 2>/dev/null

    Find setuid and setgid executables. Useful for a security audit.

  • pgrep -la nginx

    Show PIDs and full command lines of processes that match a name.

all 133 linux commands