File attributes are a type of meta-data that describe and may modify how files and/or directories in a filesystem behave. Typical file attributes may, for example, indicate or specify whether a file is visible, modifiable, compressed, or encrypted. The availability of most file attributes depends on support by the underlying filesystem (such as FAT, NTFS, ext4) where attribute data must be stored along with other control structures. Each attribute can have one of two states: set and cleared. Attributes are considered distinct from other metadata, such as dates and times, filename extensions or file system permissions. In addition to files, folders, volumes and other file system objects may have attributes.
Traditionally, in DOS and Microsoft Windows, files and folders accepted four attributes:[1][2][3]
dir
and Windows apps like File Explorer do not show hidden files by default, unless asked to do so.[4]dir
and Windows apps like File Explorer do not show system files by default even when hidden files are shown, unless asked to do so.As new versions of Windows came out, Microsoft has added to the inventory of available attributes on the NTFS file system,[7] including but not limited to:[8]
Other attributes that are displayed in the "Attributes" column of Windows Explorer[7] include:
In DOS, OS/2 and Windows, the attrib
command in cmd.exe and command.com can be used to change and display the four traditional file attributes.[3][9] File Explorer in Windows can show the seven mentioned attributes but cannot set or clear the System attribute.[5]Windows PowerShell, which has become a component of Windows 7 and later, features two commands that can read and write attributes: Get-ItemProperty
and Set-ItemProperty
.[10] To change an attribute on a file on Windows NT, the user must have appropriate file system permissions known as Write Attributes and Write Extended Attributes.[11]
In Unix and Unix-like systems, including POSIX-conforming systems, each file has a 'mode' containing 9 bit flags controlling read, write and execute permission for each of the file's owner, group and all other users (see File-system permissions §Traditional Unix permissions for more details) plus the setuid and setgid bit flags and a 'sticky' bit flag. The mode also specifies the file type (regular file, directory, or some other special kind).
In 4.4BSD and 4.4BSD-Lite, files and directories (folders) accepted four attributes that could be set by the owner of the file or the superuser (the "User" attributes) and two attributes that could only be set by the superuser (the "System" attributes):[12]
FreeBSD added some additional attributes,[13] also supported by DragonFly BSD:[14]
FreeBSD also supports:[13]
whereas DragonFly BSD supports:[14]
NetBSD added another attribute,[15] also supported by OpenBSD:[16]
macOS added three attributes:
In these systems, the chflags
and ls
commands can be used to change and display file attributes. To change a "user" attribute on a file in 4.4BSD-derived operating systems, the user must be the owner of the file or the superuser; to change a "system" attribute, the user must be the superuser.
The Linux operating system can support a wide range of file attributes that can be listed by the lsattr
command and modified, where possible, by the chattr
command.
Programs can examine and alter attributes using ioctl operations.[18]
Many Linux file systems support only a limited set of attributes, and none of them support every attribute that chattr
can change. File systems that support at least some attributes include ext4, XFS and btrfs.
Attribute | lsattr flag | chattr option | Semantics and rationale |
---|---|---|---|
No atime updates
|
A
|
+A,-A
|
atime record is not modified when file is read/accessed. |
Append-only | a
|
+a,-a
|
Writing to file only allowed in append mode. |
Immutable | i
|
+i,-i
|
Prevents any change to file's contents or metadata: file/directory cannot be written to, deleted, renamed, or hard-linked. |
No dump | d
|
+d,-d
|
File is skipped by the dump program |
Secure deletion | s
|
+s,-s
|
Requests that, when deleted, all file data blocks are filled with zeroes. |
Synchronous updates | S
|
+S,-S
|
Changes are written synchronously to the underlying filesystem storage medium; equivalent to 'sync' mount option for affected files. |
By: Wikipedia.org
Edited: 2021-06-18 18:48:36
Source: Wikipedia.org