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 macOS, have sets of "system" and "user" attributes; newer versions of the Linux kernel also support a set of file attributes.


DOS and Windows

Traditionally, in DOS and Microsoft Windows, files and folders accepted four attributes:[1][2][3]

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]

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]

FreeBSD added some additional attributes,[9] also supported by DragonFly BSD:[10]

FreeBSD also supports:[9]

whereas DragonFly BSD supports:[10]

NetBSD added another attribute,[11] also supported by OpenBSD:[12]

macOS added another attribute:[13]


In DOS, OS/2 and Windows, the attrib command in cmd.exe and 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


  1. "Definition of: file attribute". PC Magazine. Ziff Davis. Retrieved 2 December 2012.
  2. "File attributes". Computer Hope. Retrieved 2 December 2012.
  3. 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.
  4. "What is a hidden file?". Windows 7 Help. Microsoft. Retrieved 2 December 2012.
  5. 1 2 "You cannot view or change the Read-only or the System attributes of folders in Windows Server 2003, in Windows XP, in Windows Vista or in Windows 7". Microsoft Support. Microsoft. 31 May 2012. Retrieved 2 December 2012.
  6. "File Attribute Constants (Windows)". MSDN. Microsoft. Retrieved 2 December 2012.
  7. "HOW TO: Use the File Attribute Management Script ( in Windows 2000". Microsoft support. Microsoft. Retrieved 2 December 2012.
  8. chflags(2)  BSD System Calls Manual
  9. 1 2 chflags(2)  FreeBSD System Calls Manual
  10. 1 2 chflags(2)  DragonFly System Calls and Error Numbers Manual
  11. chflags(2)  NetBSD System Calls Manual
  12. chflags(2)  OpenBSD System Calls Manual
  13. chflags(2)  Darwin and OS X System Calls Manual
  14. "Definition of: DOS Attrib". PC Magazine. Ziff Davis. Retrieved 2 December 2012.
  15. "Use a PowerShell Cmdlet to Work with File Attributes". Hey, Scripting Guy! Blog. Microsoft. 26 January 2011. Retrieved 3 December 2012.
  16. "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.
This article is issued from Wikipedia - version of the 11/18/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.