Typically, a
file system maintains permission settings for each stored item commonly
files
File or filing may refer to:
Mechanical tools and processes
* File (tool), a tool used to remove fine amounts of material from a workpiece.
**Filing (metalworking), a material removal process in manufacturing
** Nail file, a tool used to gentl ...
and
directories that either grant or deny the ability to manipulate file system items. Often the settings allow controlling access based on function such as read, change, navigate, and
execute
Execution, in capital punishment
Capital punishment, also known as the death penalty and formerly called judicial homicide, is the state-sanctioned killing of a person as punishment for actual or supposed misconduct. The sentence (law), s ...
and to different
users
Ancient Egyptian roles
* User (ancient Egyptian official), an ancient Egyptian nomarch (governor) of the Eighth Dynasty
* Useramen, an ancient Egyptian vizier also called "User"
Other uses
* User (computing), a person (or software) using an ...
and groups of users. One well-established technology was developed for
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
and later codified by
POSIX
The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
. Another common technology is an
access-control list
In computer security, an access-control list (ACL) is a list of permissions associated with a system resource (object or facility). An ACL specifies which users or system processes are granted access to resources, as well as what operations are al ...
(ACL) with multiple variants implemented in file systems and one codified by POSIX. Since POSIX defines both the older Unix-based technology as well as ACLs, the former is called ''traditional POSIX permissions'' for clarity even though it is not a well-known term.
A
permission-driven user interface tailors the functionality available to the user based on file system item permissions. For example, the interface might hide menu options that are not allowed based on the permissions stored for an item.
Examples
File system permissions have been implemented many ways. Some notable examples are described here.
NTFS
NT File System (NTFS) (commonly called ''New Technology File System'') is a proprietary journaling file system developed by Microsoft in the 1990s.
It was developed to overcome scalability, security and other limitations with File Allocation Tabl ...
which is in many versions of
Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
including
the current, uses ACL technology to provide permission-based access control; considered powerful yet complex.
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
file systems such as
ext2
ext2, or second extended file system, is a file system for the Linux kernel (operating system), kernel. It was initially designed by French software developer Rémy Card as a replacement for the extended file system (ext). Having been designed ...
,
ext3
ext3, or third extended filesystem, is a journaling file system, journaled file system that is commonly used with the Linux kernel. It used to be the default file system for many popular Linux distributions but generally has been supplanted by ...
,
ext4
ext4 (fourth extended filesystem) is a journaling file system for Linux, developed as the successor to ext3.
ext4 was initially a series of backward-compatible extensions to ext3, many of them originally developed by Cluster File Systems for ...
,
Btrfs
Btrfs (pronounced as "better F S", "butter F S", "b-tree F S", or "B.T.R.F.S.") is a computer storage format that combines a file system based on the copy-on-write (COW) principle with a logical volume manager (distinct from Linux's LVM), d ...
support both POSIX permissions and POSIX.1e ACLs. There is experimental support for NFSv4 ACLs for ext3 and ext4 filesystems.
FreeBSD
FreeBSD is a free-software Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version was released in 1993 developed from 386BSD, one of the first fully functional and free Unix clones on affordable ...
supports POSIX.1e ACLs on UFS, and NFSv4 ACLs on UFS and ZFS.
HFS HFS may refer to:
Businesses and organisations
* Croatian Film Association ()
* Hellenic Fire Service, Greece
* Hospitality Franchise Systems, US
Computing
* Hierarchical file system, a system for organizing directories and files
* Hierarchica ...
, and its successor
HFS+
HFS Plus or HFS+ (also known as Mac OS Extended or HFS Extended) is a journaling file system developed by Apple Inc. It replaced the Hierarchical File System (HFS) as the primary file system of Apple computers with the 1998 release of Mac OS 8. ...
, as implemented in the
Classic Mac OS
Mac OS (originally System Software; retronym: Classic Mac OS) is the series of operating systems developed for the Mac (computer), Macintosh family of personal computers by Apple Computer, Inc. from 1984 to 2001, starting with System 1 and end ...
operating systems, do not support permissions.
macOS
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
supports POSIX-compliant permissions, and supports them in both HFS+ and
APFS
Apple File System (APFS) is a proprietary file system developed and deployed by Apple Inc. for macOS Sierra (10.12.4) and later, iOS 10.3, tvOS 10.2, watchOS 3.2, and all versions of iPadOS. It aims to fix core problems of HFS+ (also ca ...
. Beginning with version 10.4 ("Tiger"), it also supports the use of NFSv4 ACLs in addition to POSIX-compliant permissions. The ''Apple Mac OS X Server version 10.4+ File Services Administration Manual'' recommends using only traditional Unix permissions if possible. macOS also still supports the Classic Mac OS's "Protected"/"Locked" attribute as the "user immutable" flag in
the 4.4BSD flags field.
File Allocation Table
File Allocation Table (FAT) is a file system developed for personal computers and was the default file system for the MS-DOS and Windows 9x operating systems. Originally developed in 1977 for use on floppy disks, it was adapted for use on Ha ...
(original version) has a per-file read-only attribute that applies to all users.
OpenVMS
OpenVMS, often referred to as just VMS, is a multi-user, multiprocessing and virtual memory-based operating system. It is designed to support time-sharing, batch processing, transaction processing and workstation applications. Customers using Op ...
defines four access functions: read, write, execute and delete and user selections: system, owner, group, and world where world includes group which in turn includes owner and system selects system users. This design is similar to that of Unix with notable extensions: additional function: delete and additional user selection: system. ACLs are supported in VMS 4.0 and later.
Solaris
Solaris is the Latin word for sun.
It may refer to:
Arts and entertainment Literature, television and film
* ''Solaris'' (novel), a 1961 science fiction novel by Stanisław Lem
** ''Solaris'' (1968 film), directed by Boris Nirenburg
** ''Sol ...
ACL support depends on the filesystem being used; older
UFS filesystem supports POSIX.1e ACLs, while
ZFS
ZFS (previously Zettabyte File System) is a file system with Volume manager, volume management capabilities. It began as part of the Sun Microsystems Solaris (operating system), Solaris operating system in 2001. Large parts of Solaris, includin ...
supports only NFSv4 ACLs.
IBM z/OS
z/OS is a 64-bit computing, 64-bit operating system for IBM z/Architecture Mainframe computer, mainframes, introduced by IBM in October 2000. It derives from and is the successor to OS/390, which in turn was preceded by a string of MVS vers ...
implements file security using RACF (Resource Access Control Facility)
The AmigaOS Filesystem, AmigaDOS supports a permissions system relatively advanced for a single-user OS. In AmigaOS 1.x, files had Archive, Read, Write, Execute and Delete (collectively known as ARWED) permissions/flags. In AmigaOS 2.x and higher, additional Hold, Script, and Pure permissions/flags were added.
OpenHarmony
OpenHarmony (OHOS, OH) is a family of open-source distributed operating systems based on HarmonyOS derived from LiteOS, donated the L0-L2 branch source code by Huawei to the OpenAtom Foundation. Similar to HarmonyOS, the open-source distrib ...
operating system alongside its client side ecosystem in Oniro OS and
HarmonyOS
HarmonyOS (HMOS) ( zh, s=鸿蒙, p=Hóngméng, tr=Vast Mist) is a distributed operating system developed by Huawei for smartphones, tablet computer, tablets, smart TVs, smart watches, personal computers and other smart devices. It has a microk ...
with
HarmonyOS NEXT
HarmonyOS NEXT ( zh, s=鸿蒙星河版, p=Hóngméng Xīnghébǎn) is a proprietary software, proprietary distributed operating system that succeeded the similarly named HarmonyOS, with the main difference that the "Next" operating system was de ...
versions and also
Linux-based openEuler
EulerOS is a commercial Linux distribution developed by Huawei based on Red Hat Enterprise Linux to provide an operating system for server and cloud environments. Its open-source community version is known as openEuler; the source code of openEul ...
server OS natively uses its Harmony Distributed File System (HMDFS) that supports access token manager (
role-based access control
In computer systems security, role-based access control (RBAC) or role-based security is an approach to restricting system access to authorized users, and to implementing mandatory access control (MAC) or discretionary access control, discretion ...
) and Core File Kit API capability-based with granular permission management with exception to openEuler.
Traditional POSIX permissions
Traditionally, file permissions on a Unix-based file system is defined by POSIX.1-2017,. It specifies three classes (user, group and others) that allow for mapping permissions to users and three operations (read, write, execute) that can be granted or denied for each class. When a file is created, its permissions default to that as accessible via the
umask
umask is a shell command that reports or sets the mask value that limits the file permissions for newly created files in many Unix and Unix-like file systems. A system call with the same name, , provides access to the mask value stored in the ...
command.
In a Unix-based file system, everything is a file; even
directories and other special files.
Classes
The classes determine how permissions map to a user. The ''user class'' permissions apply to the user who owns the file. The ''group class'' permissions apply to users of the file's owning
group
A group is a number of persons or things that are located, gathered, or classed together.
Groups of people
* Cultural group, a group whose members share the same cultural identity
* Ethnic group, a group whose members share the same ethnic iden ...
. The ''others class'' applies to other users.
The ''effective permissions'' are the permissions of the class in which the user falls ''first'' given the order: user, group then others. For example, the owning user has effective permissions of the user class even if they are in the owning group.
Operations
The operations that can be granted or denied include:
* ''Read'' grants the ability to read a file. When set for a directory, this permission grants the ability to read the names of contained files, but not to read other information about them such as contents, file type, size, ownership, permissions.
* ''Write'' grants the ability to modify a file. When set for a directory, this permission grants the ability to modify entries in the directory, which includes creating, deleting and renaming files. This requires that ''execute'' is also set; without it, the write permission is meaningless for directories.
* ''Execute'' grants the ability to execute a file. This permission must be set for executable programs to allow running them. When set for a directory, this permission is interpreted as the ''search'' permission granting the ability to access file contents and metadata if its name is known, but not list files in the directory, unless ''read'' is set also.
The effect of setting the permissions on a directory, rather than a file, is "one of the most frequently misunderstood file permission issues".
Unlike ACL-based systems, these permissions are not inherited. Files created within a directory do not necessarily have the same permissions as its containing directory.
Changing permission behavior with setuid, setgid, and sticky bits
Three additional single-bit attributes apply to each file that are related to permissions and stored in the file mode along with permissions.
* The ''
set user ID'', ''setuid'', or SUID mode. Executing a file with this bit set results in a process with
user ID
Unix-like operating systems identify a user by a value called a user identifier, often abbreviated to user ID or UID. The UID, along with the group identifier (GID) and other access control criteria, is used to determine which system resources a us ...
set to the file's owning user. This enables users to be treated temporarily as root (or another user).
* The ''
set group ID'', ''setgid'', or SGID permission. Executing a file with this bit set results in a process with
group ID
In Unix-like systems, multiple users can be put into '' groups''. POSIX and conventional Unix file system permissions are organized into three classes, ''user'', ''group'', and ''others''. The use of groups allows additional abilities to be dele ...
set to the file's owning group. When applied to a directory, new files and directories created under that directory inherit their group from that directory. (Default behavior is to use the primary group of the effective user when setting the group of new files and directories, except on BSD-derived systems which behave as though the setgid bit is always set on all directories (see
Setuid
The Unix and Linux access rights flags setuid and setgid (short for ''set user identity'' and ''set group identity'') allow users to run an executable with the file system permissions of the executable's owner or group respectively and to chang ...
).)
* The ''
sticky'' mode (also known as the ''Text'' mode). The classical behavior of the sticky bit on executable files has been to encourage the
kernel
Kernel may refer to:
Computing
* Kernel (operating system), the central component of most operating systems
* Kernel (image processing), a matrix used for image convolution
* Compute kernel, in GPGPU programming
* Kernel method, in machine learnin ...
to retain the resulting process image in memory beyond termination; however, such use of the sticky bit is now restricted to only a minority of Unix-like operating systems (
HP-UX
HP-UX (from "Hewlett Packard Unix") is a proprietary software, proprietary implementation of the Unix operating system developed by Hewlett Packard Enterprise; current versions support HPE Integrity Servers, based on Intel's Itanium architect ...
and
UnixWare
UnixWare is a Unix operating system. It was originally released by Univel, a jointly owned venture of AT&T's Unix System Laboratories (USL) and Novell. It was then taken over by Novell. Via Santa Cruz Operation (SCO), it went on to Caldera Syst ...
). On a directory, the sticky permission prevents users from renaming, moving or deleting contained files owned by users other than themselves, even if they have write permission to the directory. Only the directory owner and superuser are exempt from this.
Representation
Permissions are commonly represented in symbolic or octal notation.
Symbolic notation
Symbolic notation is used in the long output format of command
ls -l
.
The first character of the output indicates the
Unix file type
The Unix file types are the categories of file formats that a Unix-based system uses to provide context-sensitive behavior of file system items all of which called ''files'' in Unix-based systems. POSIX defines categories: regular, directory, sy ...
which is not a permission even though its next to the permissions information. The remaining nine characters represent the grants for the user, group and others classes as groups of operation grants for read, write and execute. An operation is denied when shown as a dash or granted when shown as for read, for write or for execute.
Examples:
*
-rwxr-xr-x
: initial indicates a regular file, next three indicate that user class has all permissions and group and others classes (both ) have only read and execute
*
crw-rw-r--
: initial indicates a character special file, user and group classes (both ) have read and write permissions and others class () has only read permission
*
dr-x------
: initial ) indicates a directory, user class () has read and execute permissions and group and others classes (both ) have no permissions
To represent the ''setuid'', ''setgid'' and ''sticky/text'' attributes, the character in the third position for a class is modified; even though this position is otherwise only for execute and even though these attributes affect the file without concern for class. The setuid attribute modifies the execute character for the user class, the setgid attribute modifies the execute character for the group class, and the sticky or text attribute modifies the execute character for the others class. For setuid or setgid,
x
becomes
s
and
-
becomes
S
. For the sticky or text attribute
x
becomes
t
and
-
becomes
T
. For example
-rwsr-Sr-t
indicates a regular file, user class has read, write and execute permissions; group class has read permission; others class has read and execute permissions; and which has ''setuid'', ''setgid'' and ''sticky'' attributes set.
Some systems show additional permission features:
* suffix indicates an access control list that can control additional permissions
* suffix indicates an
SELinux
Security-Enhanced Linux (SELinux) is a Linux kernel security module that provides a mechanism for supporting access control security policies, including mandatory access controls (MAC).
SELinux is a set of kernel modifications and user-space too ...
context is present. Details may be listed with the command
ls -Z
* suffix indicates
extended file attributes
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 (such as permissions or ...
are present
Octal notation
Permissions are often shown in
octal
Octal (base 8) is a numeral system with eight as the base.
In the decimal system, each place is a power of ten. For example:
: \mathbf_ = \mathbf \times 10^1 + \mathbf \times 10^0
In the octal system, each place is a power of eight. For ex ...
notation; for example via the command
stat -c %a
. The notation consists of at least three digits. The last three digits represent the permission by class: user, group, and others. If a fourth digit is present, the leftmost represents the three special attributes: ''setuid'', ''setgid'' and ''sticky''.
Each operation grant is assigned a bit position that for an octal digit is:
* Read: left, binary 100, octal 4
* Write: middle, binary 010, octal 2
* Execute: right, binary 001, octal 1
A class permission value is the sum or alternatively the
logic OR of the grants.
Examples:
User private group
Some systems diverge from the traditional POSIX model of users and groups by creating a new group – a "user private group" – for each user. Assuming that each user is the only member of its user private group, this scheme allows an umask of 002 to be used without allowing other users to write to newly created files in normal directories because such files are assigned to the creating user's private group. However, when sharing files is desirable, the administrator can create a group containing the desired users, create a group-writable directory assigned to the new group, and, most importantly, make the directory setgid. Making it setgid will cause files created in it to be assigned to the same group as the directory and the 002 umask (enabled by using user private groups) will ensure that other members of the group will be able to write to those files.
See also
*
chattr
is the command in Linux that allows a user to set certain attributes of a file. is the command that displays the attributes of a file.
Most BSD-like systems, including macOS, have always had an analogous command to set the attributes, but ...
or chflags Change attributes or flags including those which restrict access
*
*
lsattr List attributes
*
Comparison of file systems § Metadata
References
External links
The Linux Cookbook: Groups and How to Work in Themby Michael Stutz 2004
{{DEFAULTSORT:Filesystem permissions