File attribute
File attributes are metadata associated with computer files that define file system behavior. 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 MS-DOS and Microsoft Windows, there were four attributes: archive, hidden, read-only and system. Windows has added new ones. Systems derived from 4.4BSD-Lite, such as FreeBSD, NetBSD, OpenBSD, DragonFly BSD, and OS X, have sets of "system" and "user" attributes; newer versions of the Linux kernel also support a set of file attributes.
Types
DOS and Windows
Traditionally, in DOS and Microsoft Windows, files and folders accepted four attributes:[1][2][3]
- Archive: 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 backup.
- Hidden: 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.[4] - System: 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: 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.[5]
As new versions of Windows came out, Microsoft has added to the inventory of available attributes on the NTFS file system,[6] including but not limited to:[7]
- Compressed: When set, Windows compresses the hosting file upon storage. For more information, see NTFS § File compression.
- Encrypted: When set, Windows encrypts the hosting file upon storage to prevent unauthorized access. For more information, see NTFS § Encryption.
- Indexed: When set, Indexing Service or Windows Search do not include the hosting file in their indexing operation.
4.4BSD-Lite and derivatives
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):[8]
- (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.
FreeBSD added some additional attributes,[9] also supported by DragonFly BSD:[10]
- (User and System) No-unlink: When set, indicates that the file or directory should not be renamed or removed. Attempts to rename or remove the file or directory will fail with a permissions error.
FreeBSD also supports:[9]
- (System) No-archive: When set, indicates that the file or directory should not be archived.
- (System) Snapshot: When set, indicates that the file or directory is a snapshot file. This attribute is maintained by the system, and cannot be set, even by the super-user.
whereas DragonFly BSD supports:[10]
- (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 disk.
- (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 disk.
- (System) Archived: When set, indicates that the file or directory may be archived.
NetBSD added another attribute,[11] also supported by OpenBSD:[12]
- (System) Archived: When set, indicates that the file or directory is archived.
OS X added another attribute:[13]
- (User) Hidden: When set, indicates that the file or directory should not, by default, be displayed in the GUI; ls will display it, however.
Editing
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][14] 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
.[15] 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.[16]
In 4.4BSD and 4.4BSD-Lite and derivatives, 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.
In Linux, the chattr
and lsattr
commands can be used to change and display file attributes.
See also
References
- ↑ "Definition of: file attribute". PC Magazine. Ziff Davis. Retrieved 2 December 2012.
- ↑ "File attributes". Computer Hope. Retrieved 2 December 2012.
- 1 2 "In Windows, what are file attributes, and how can I change them?". Knowledge Base. Indiana University. 11 October 2011. Retrieved 2 December 2012.
- ↑ "What is a hidden file?". Windows 7 Help. Microsoft. Retrieved 2 December 2012.
- ↑ "File Attribute Constants (Windows)". MSDN. Microsoft. Retrieved 2 December 2012.
- ↑ "HOW TO: Use the File Attribute Management Script (Fileattributes.pl) in Windows 2000". Microsoft support. Microsoft. Retrieved 2 December 2012.
- ↑ – BSD System Calls Manual
- 1 2 – FreeBSD System Calls Manual
- 1 2 – DragonFly System Calls and Error Numbers Manual
- ↑ – NetBSD System Calls Manual
- ↑ – OpenBSD System Calls Manual
- ↑ – Darwin and OS X System Calls Manual
- ↑ "Definition of: DOS Attrib". PC Magazine. Ziff Davis. Retrieved 2 December 2012.
- ↑ "Use a PowerShell Cmdlet to Work with File Attributes". Hey, Scripting Guy! Blog. Microsoft. 26 January 2011. Retrieved 3 December 2012.
- ↑ "How to set, view, change, or remove special permissions for files and folders in Windows XP". Microsoft Support. Microsoft. 7 May 2007. Retrieved 2 December 2012.
External links
- Definition of: DOS Attrib on PC Magazine
- Hidden files in Unix-like operating systems at the Wayback Machine (archived October 17, 2007)
|