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]
The command line tools chattr (to manipulate attributes) and lsattr (to list attributes) were originally specific to the Second Extended Filesystem family (ext2, ext3, ext4), and are available as part of the e2fsprogs package.
However, the functionality has since been extended, fully or partially, to many other systems, including XFS, ReiserFS, JFS and OCFS2. The btrfs file system includes the attribute functionality, including the C flag, which turns off the built-in copy-on-write (CoW) feature of btrfs due to slower performance associated with CoW.
C
The form of the chattr command is:
chattr [-RVf] [-+=AacDdijsTtSu] [-v version] files...
-R
-V
-f
The form of the lsattr command (gnu 1.41.3):
lsattr [ -RVadv ] [ files... ]
-a
-d
Some attributes include:
chattr(1)
atime
A
+A
-A
a
+a
c
+c
-c
+C
-C
D
+D
-D
dirsync
d
+d
E
e
h
I
i
+i
-i
j
+j
-j
"data=ordered"
"data=writeback"
"data=journal"
s
+s
-s
S
+S
-S
sync
T
+T
-T
/home
/home/john
/home/mary
t
+t
-t
u
+u
-u
X
Z
-v
-v version
CAP_LINUX_IMMUTABLE
CAP_SYS_RESOURCE
The chflags command is not specific to particular file systems. UFS on BSD systems, and APFS, HFS+, SMB, AFP, and FAT on macOS support at least some flags.
The form of the chflags command is:
chflags [-R [-H | -L | -P]] flags file ...
-H
-L
-P
BSD-like systems, in general, have no default user-level command specifically meant to display the flags of a file. The ls command will do with either the -lo, or the -lO, depending on the system, flags passed.
-lo
-lO
All traditional attributes can be set or cleared by the super-user; some can also be set or cleared by the owner of the file. Some attributes include:
ATTRIB
chown
chmod
cacls
chmod(1)
ls(1)
chflags(1)
lsattr(1)
Lokasi Pengunjung: 3.135.182.79