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.
Archive (A): When set, it indicates that the hosting file has changed since the last backup operation. Windows' file system sets this attribute on any file that has changed. Backup software then has the duty of clearing it upon a successful full or incremental backup (not a differential one).
Hidden (H): When set, indicates that the hosting file is hidden. MS-DOS commands like dir and Windows apps like File Explorer do not show hidden files by default, unless asked to do so.
System (S): When set, indicates that the hosting file is a critical system file that is necessary for the computer to operate properly. MS-DOS and Microsoft Windows use it to mark important system files. MS-DOS commands like 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.
Read-only (R): When set, indicates that a file should not be altered. Upon opening the file, file system API usually does not grant write permission to the requesting application, unless the application explicitly requests it. Read-only attributes on folders are usually ignored, being used for another purpose.
As new versions of Windows came out, Microsoft has added to the inventory of available attributes on the NTFS file system, including but not limited to:
Other attributes that are displayed in the "Attributes" column of Windows Explorer include:
Directory (D): The entry is a subdirectory, containing file and directory entries of its own.
Reparse Point (L): The file or directory has an associated re-parse point, or is a symbolic link.
Not Indexed (N): The file is not indexed on the host device.
Offline (O): The file data is physically moved to offline storage (Remote Storage).
Sparse (P): The file is a sparse file, i.e., its contents are partially empty and non-contiguous.
Temporary (T): The file is used for temporary storage.
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. File Explorer in Windows can show the seven mentioned attributes but cannot set or clear the System attribute.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. 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.
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):
(User) No-dump: When set, it indicates that the file or directory should not be saved during a backup operation.
(User and System) Immutable: When set, indicates that the file or directory should not be altered. Attempts to open the file for writing, create a file within the directory, remove a file from the directory, rename a file within the directory, rename the file or directory, or remove the file or directory will fail with a permissions error.
(User and System) Append-only: When set, indicates that the file should only be appended to.
(User) Opaque: When set on a directory, indicates that the directory is opaque when viewed through a union stack.
(User and System) No-history: When set, indicates that history should not be retained for the file or directory.
(User) Swapcache: When set, indicates that clean filesystem data for the file, or for the directory and everything underneath the directory, should be cached in swap space on a solid-state drive.
(System) Swapcache: When set, indicates that clean filesystem data for the file, or for the directory and everything underneath the directory, should not be cached in swap space on a solid-state drive.
(System) Archived: When set, indicates that the file or directory may be archived.
(User and System) Compressed: Read-only attribute for files compressed using HFS+ Compression
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 commmand.
Programs can examine and alter attributes using ioctl operations.
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.
Common file attributes supported by many common Linux file systems