File attribute

Last updated

File attributes are a type of metadata 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.

Contents

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, [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]

Unix and POSIX

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).

4.4BSD 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): [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.

Linux

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.

Common file attributes supported by many common Linux file systems
Attributelsattr flagchattr optionSemantics and rationale
No atime updatesA+A,-A atime record is not modified when file is read/accessed.
Append-onlya+a,-a

Writing to file only allowed in append mode.

Immutablei+i,-i

Prevents any change to file's contents or metadata: file/directory cannot be written to, deleted, renamed, or hard-linked.

No dumpd+d,-dFile is skipped by the dump program
Secure deletions+s,-sRequests that, when deleted, all file data blocks are filled with zeroes.
Synchronous updatesS+S,-SChanges are written synchronously to the underlying filesystem storage medium; equivalent to 'sync' mount option for affected files.

OpenSolaris and derivatives

Support for "system attributes" (in which the operating system defines the meaning, unlike general extended file attributes) was added to OpenSolaris in 2007 in support of the CIFS server. [19] It has been carried forward from there into both the Oracle Solaris 11 releases and the open source illumos project.

In this implementation, a wide range of attributes can be set via the chmod command [20] [21] and listed by the ls command. [22] [23] Programs can examine and alter attributes using the getattrat and setattrat functions. [24] [25]

Currently the ZFS file system supports all defined attributes, and starting in Oracle Solaris 11.2, the tmpfs file system supports a subset of attributes. [26]

Common file attributes supported by Oracle Solaris and illumos systems
AttributeCompact flag for ls & chmodSemantics and rationale
appendonlya

Writing to file only allowed in append mode.

immutablei

Prevents any change to file's contents or metadata (except access time): file/directory cannot be written to, deleted, or renamed.

nodumpdFile should be skipped by backup programs
nounlinkuPrevents removing the file, but allows other changes.

See also

Related Research Articles

NT File System (NTFS) is a proprietary journaling file system developed by Microsoft in the 1990s.

<span class="mw-page-title-main">Disk partitioning</span> Creation of separate accessible storage areas on a secondary computer storage device

Disk partitioning or disk slicing is the creation of one or more regions on secondary storage, so that each region can be managed separately. These regions are called partitions. It is typically the first step of preparing a newly installed disk after a partitioning scheme is chosen for the new disk before any file system is created. The disk stores the information about the partitions' locations and sizes in an area known as the partition table that the operating system reads before any other part of the disk. Each partition then appears to the operating system as a distinct "logical" disk that uses part of the actual disk. System administrators use a program called a partition editor to create, resize, delete, and manipulate the partitions. Partitioning allows the use of different filesystems to be installed for different kinds of files. Separating user data from system data can prevent the system partition from becoming full and rendering the system unusable. Partitioning can also make backing up easier. A disadvantage is that it can be difficult to properly size partitions, resulting in having one partition with too much free space and another nearly totally allocated.

An 8.3 filename is one that obeys the filename convention used by old versions of DOS and versions of Microsoft Windows prior to Windows 95 and Windows NT 3.5. It is also used in modern Microsoft operating systems as an alternate filename to the long filename, to provide compatibility with legacy programs. The filename convention is limited by the FAT file system. Similar 8.3 file naming schemes have also existed on earlier CP/M, TRS-80, Atari, and some Data General and Digital Equipment Corporation minicomputer operating systems.

In computer security, an access-control list (ACL) is a list of permissions associated with a system resource. An ACL specifies which users or system processes are granted access to resources, as well as what operations are allowed on given resources. Each entry in a typical ACL specifies a subject and an operation. For instance,

In computing, a symbolic link is a file whose purpose is to point to a file or directory by specifying a path thereto.

A home directory is a file system directory on a multi-user operating system containing files for a given user of the system. The specifics of the home directory are defined by the operating system involved; for example, Linux / BSD (FHS) systems use /home/⟨username⟩ or /usr/home/⟨username⟩ and Windows systems since Windows Vista use \Users\⟨username⟩.

fstab is a system file commonly found in the directory /etc on Unix and Unix-like computer systems. In Linux, it is part of the util-linux package. The fstab file typically lists all available disk partitions and other types of file systems and data sources that may not necessarily be disk-based, and indicates how they are to be initialized or otherwise integrated into the larger file system structure.

These tables provide a comparison of operating systems, of computer devices, as listing general and technical information for a number of widely used and currently available PC or handheld operating systems. The article "Usage share of operating systems" provides a broader, and more general, comparison of operating systems that includes servers, mainframes and supercomputers.

<span class="mw-page-title-main">File system</span> Computer filing system

In computing, a file system or filesystem governs file organization and access. A local file system is a capability of an operating system that services the applications running on the same computer. A distributed file system is a protocol that provides file access between networked computers.

<span class="mw-page-title-main">DTrace</span> Dynamic tracing framework for kernel and applications

DTrace is a comprehensive dynamic tracing framework originally created by Sun Microsystems for troubleshooting kernel and application problems on production systems in real time. Originally developed for Solaris, it has since been released under the free Common Development and Distribution License (CDDL) in OpenSolaris and its descendant illumos, and has been ported to several other Unix-like systems.

Most file systems include attributes of files and directories that control the ability of users to read, change, navigate, and execute the contents of the file system. In some cases, menu options or functions may be made visible or hidden depending on a user's permission level; this kind of user interface is referred to as permission-driven.

rm (Unix) Unix command utility

rm is a basic command on Unix and Unix-like operating systems used to remove objects such as computer files, directories and symbolic links from file systems and also special files such as device nodes, pipes and sockets, similar to the del command in MS-DOS, OS/2, and Microsoft Windows. The command is also available in the EFI shell.

In computing, privilege is defined as the delegation of authority to perform security-relevant functions on a computer system. A privilege allows a user to perform an action with security consequences. Examples of various privileges include the ability to create a new user, install software, or change kernel functions.

In computing, the sticky bit is a user ownership access right flag that can be assigned to files and directories on Unix-like systems.

Extended file attributes are file system features that enable users to associate computer files with metadata not interpreted by the filesystem, whereas regular attributes have a purpose strictly defined by the filesystem. Unlike forks, which can usually be as large as the maximum file size, extended attributes are usually limited in size to a value significantly smaller than the maximum file size. Typical uses include storing the author of a document, the character encoding of a plain-text document, or a checksum, cryptographic hash or digital certificate, and discretionary access control information.

The following tables compare general and technical information for a number of file systems.

In computing, a hidden folder or hidden file is a folder or file which filesystem utilities do not display by default when showing a directory listing. They are commonly used for storing user preferences or preserving the state of a utility and are frequently created implicitly by using various utilities. They are not a security mechanism because access is not restricted – usually the intent is simply to not "clutter" the display of the contents of a directory listing with files the user did not directly create.

The NTFS file system defines various ways to redirect files and folders, e.g., to make a file point to another file or its contents without making a copy of it. The object being pointed to is called the target. Such file is called a hard or symbolic link depending on a way it's stored on the filesystem.

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.

References

  1. "Definition of: file attribute". PC Magazine . Ziff Davis . Retrieved 14 October 2020.
  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. "Why is the readonly property on folders so strange?".
  7. 1 2 "File Attribute Constants". MSDN . Microsoft . Retrieved 17 July 2018.
  8. "HOW TO: Use the File Attribute Management Script (Fileattributes.pl) in Windows 2000". Microsoft support. Microsoft. Retrieved 2 December 2012.
  9. "Definition of: DOS Attrib". PC Magazine . Ziff Davis. Archived from the original on 2 March 2012. Retrieved 2 December 2012.
  10. "Use a PowerShell Cmdlet to Work with File Attributes". Hey, Scripting Guy! Blog. Microsoft. 26 January 2011. Retrieved 3 December 2012.
  11. "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.
  12. chflags(2)    BSD System Calls Manual
  13. 1 2 chflags(2)    FreeBSD System Calls Manual
  14. 1 2 chflags(2)    DragonFly BSD System Calls and Error Numbers Manual
  15. chflags(2)    NetBSD System Calls Manual
  16. chflags(2)    OpenBSD System Calls Manual
  17. chflags(2)    Darwin and macOS System Calls Manual
  18. ioctl_iflags(2)    Linux Programmer's Manual – System Calls
  19. Shellenbaum, Mark. "Extensible Attribute Interfaces [PSARC/2007/315]". OpenSolaris ARC Material Archive. illumos.org. Retrieved 10 March 2023.
  20. "chmod(1)". Oracle Solaris 11.4 Reference Library: man pages section 1: User Commands. Oracle. Retrieved 10 March 2023.
  21. "chmod(1)". illumos man pages. illumos.org. Retrieved 10 March 2023.
  22. "ls(1)". Oracle Solaris 11.4 Reference Library: man pages section 1: User Commands. Oracle. Retrieved 10 March 2023.
  23. "ls(1)". illumos man pages. illumos.org. Retrieved 10 March 2023.
  24. "getattrat(3c)/setattrat(3c)". Oracle Solaris 11.4 Reference Library: man pages section 3: Basic Library Functions. Oracle. Retrieved 10 March 2023.
  25. "getattrat(3c)/setattrat(3c)". illumos man pages. illumos.org. Retrieved 10 March 2023.
  26. "sysattr(7)". Oracle Solaris 11.4 Reference Library: man pages section 7. Oracle. Retrieved 10 March 2023.