Chattr

chattr
Original author(s)Remy Card
Operating systemLinux
PlatformCross-platform
TypeCommand
chflags
Operating systemBSD-like systems, including macOS
PlatformCross-platform
TypeCommand

chattr is the command in Linux that allows a user to set certain attributes of a file. lsattr is the command that displays the attributes of a file.

Most BSD-like systems, including macOS, have always had an analogous chflags command to set the attributes, but no command specifically meant to display them; specific options to the ls command are used instead. The chflags command first appeared in 4.4BSD.

Solaris has no commands specifically meant to manipulate them. chmod[1] and ls[2] are used instead.

Other Unix-like operating systems, in general, have no analogous commands. The similar-sounding commands chatr (from HP-UX) and lsattr (from AIX) exist but have unrelated functions.

Among other things, the chattr command is useful to make files immutable so that password files and certain system files cannot be erased during software upgrades.[3]

  1. ^ chmod(1) – illumos and OpenSolaris User Commands Reference Manual from latest Sun based OpenSolaris
  2. ^ ls(1) – illumos and OpenSolaris User Commands Reference Manual from latest Sun based OpenSolaris
  3. ^ chflags(1) – OpenBSD General Commands Manual