All Topics  
File system permissions

 

   Email Print
   Bookmark   Link






 

File system permissions



 
 
Most modern file system
File system

In computing, a file system is a method for store and organize computer files and the data they contain to make it easy to find and access them....
s have methods of administering permissions or access rights to specific users
User (computing)

In computing, a user is a person who uses a computer or Internet service. A user may have a user account that identifies the user by a username , screenname , or "handle", which is derived from the identical Citizen's Band radio term....
 and groups of users. These systems control the ability of the users affected to view or make changes to the contents of the file system
File system

In computing, a file system is a method for store and organize computer files and the data they contain to make it easy to find and access them....
.

lass="link1" onMouseover='showByLink("m3385264",this)' onMouseout='hide("m3385264")'href="http://www.absoluteastronomy.com/topics/Unix-like">Unix-like
Unix-like

A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
 and otherwise POSIX
POSIX

POSIX or "Portable Operating System Interface" is the collective name of a family of related standardizations specified by the Institute of Electrical and Electronics Engineers to define the application programming interface , along with shell and utilities interfaces for software compatible with variants of the Unix operating system, altho...
-compliant systems, including Linux
Linux

Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU GPL license...
-based systems and all Mac OS X
Mac OS X

Mac OS X is a line of computer operating systems developed, marketed, and sold by Apple Inc., and since 2002 has been included with all new Macintosh computer systems....
 versions, have a simple system for managing individual file permissions, which in this article are called "traditional Unix permissions".






Discussion
Ask a question about 'File system permissions'
Start a new discussion about 'File system permissions'
Answer questions from other users
Full Discussion Forum



Encyclopedia


Most modern file system
File system

In computing, a file system is a method for store and organize computer files and the data they contain to make it easy to find and access them....
s have methods of administering permissions or access rights to specific users
User (computing)

In computing, a user is a person who uses a computer or Internet service. A user may have a user account that identifies the user by a username , screenname , or "handle", which is derived from the identical Citizen's Band radio term....
 and groups of users. These systems control the ability of the users affected to view or make changes to the contents of the file system
File system

In computing, a file system is a method for store and organize computer files and the data they contain to make it easy to find and access them....
.

Differences between operating systems

Unix-like
Unix-like

A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
 and otherwise POSIX
POSIX

POSIX or "Portable Operating System Interface" is the collective name of a family of related standardizations specified by the Institute of Electrical and Electronics Engineers to define the application programming interface , along with shell and utilities interfaces for software compatible with variants of the Unix operating system, altho...
-compliant systems, including Linux
Linux

Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU GPL license...
-based systems and all Mac OS X
Mac OS X

Mac OS X is a line of computer operating systems developed, marketed, and sold by Apple Inc., and since 2002 has been included with all new Macintosh computer systems....
 versions, have a simple system for managing individual file permissions, which in this article are called "traditional Unix permissions". Most of these systems also support some kind of access control list
Access control list

With respect to a computer filesystem, an access control list is a list of permissions attached to an object. The list specifies who or what is allowed to access the object and what operations are allowed to be performed on the object....
s, either proprietary (old HP-UX ACLs, for example), or POSIX.1e ACLs, based on early POSIX draft that was abandoned, or NFSv4 ACLs, which are the part of NFSv4 standard.

DOS
DOS

DOS, short for "Disk Operating System", is a shorthand term for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions Windows 95, Windows 98, and Windows Me....
 variants (including the Microsoft products MS-DOS
MS-DOS

MS-DOS is an operating system commercialized by Microsoft. It was the most commonly used member of the DOS family of operating systems and was the main operating system for personal computers during the 1980s....
, Windows 95
Windows 95

Windows 95 is a consumer-oriented graphical user interface-based operating system. It was released on August 24, 1995 by Microsoft, and was a significant progression from the company's previous Microsoft Windows products....
, Windows 98
Windows 98

Windows 98 is a graphical operating system released on 25 June 1998 by Microsoft and the successor to Windows 95. Like its predecessor, it is a hybrid 16-bit application/32-bit application monolithic product based on MS-DOS....
, and Windows Me
Windows Me

Windows Millennium Edition, or Windows Me , is a hybrid 16-bit/32-bit graphical operating system released on 14 September 2000 by Microsoft....
) do not have permissions. There is a "read-only
Read-only

Read-only generally refers to something that can be read, but not written to or modified.In computing, read-only can mean:* Read-only memory , a type of storage media...
" attribute that can be set or unset on a file by any user or program.

VMS and OpenVMS
OpenVMS

OpenVMS , previously known as VAX-11/VMS, VAX/VMS or VMS, is the name of a high-end computer server operating system that runs on the VAX and DEC Alpha families of computers, developed by Digital Equipment Corporation of Maynard, Massachusetts, Massachusetts , and most recently on Hewlett-Packard systems built around the In...
 as well as Microsoft Windows NT
Windows NT

Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was originally designed to be a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix....
 and its derivatives (including Windows 2000
Windows 2000

Windows 2000 is a line of operating systems produced by Microsoft for use on business desktops, Laptop, and Server . Released on 17 February, 2000, it was the successor to Windows NT 4.0, and is the final release of Microsoft Windows to display the "Windows NT" designation....
 and Windows XP
Windows XP

Windows XP is a line of operating systems produced by Microsoft for use on personal computers, including home and business desktops, laptop, and media centers....
), use access control list
Access control list

With respect to a computer filesystem, an access control list is a list of permissions attached to an object. The list specifies who or what is allowed to access the object and what operations are allowed to be performed on the object....
s (ACLs) to administer a more complex and varied set of permissions.

Classic Mac OSes
Mac OS history

On January 24, 1984, Apple Computer, Inc. introduced the Macintosh personal computer, with the Macintosh 128K model, which came bundled with the Mac OS operating system, then known as the System Software....
 are similar to DOS variants and DOS based Windows: they do not support permissions, but only a "Protected" file attribute.

Mac OS X
Mac OS X

Mac OS X is a line of computer operating systems developed, marketed, and sold by Apple Inc., and since 2002 has been included with all new Macintosh computer systems....
 versions 10.3 ("Panther") and prior use POSIX-compliant permissions.

Mac OS X
Mac OS X

Mac OS X is a line of computer operating systems developed, marketed, and sold by Apple Inc., and since 2002 has been included with all new Macintosh computer systems....
, beginning with version 10.4 ("Tiger"), also support the use of NFSv4 ACL
Access control list

With respect to a computer filesystem, an access control list is a list of permissions attached to an object. The list specifies who or what is allowed to access the object and what operations are allowed to be performed on the object....
s. They still support "traditional Unix permissions" as used in previous versions of Mac OS X, and the Apple Mac OS X Server version 10.4+ File Services Administration Manual recommends using only traditional Unix permissions if possible. It also still supports the Mac OS Classic's "Protected" attribute.

Solaris ACL support depends on the filesystem being used - older UFS
UFS

UFS may refer to:* Unix File System, a file system used by many Unix and Unix-like operating systems* United Feature Syndicate, commonly known as United Media...
 filesystem supports POSIX.1e ACLs, while ZFS
ZFS

In computing, ZFS is a file system designed by Sun Microsystems for the Solaris Operating System. The features of ZFS include support for high storage capacities, integration of the concepts of filesystem and volume , Snapshot and copy-on-write clones, continuous integrity checking and automatic repair, RAID-Z and native NFSv4 ACLs....
 supports only NFSv4 ACLs.

Linux
Linux

Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU GPL license...
 supports POSIX.1e ACLs. There is experimental support for NFSv4 ACLs for ext3
Ext3

The ext3 or third extended filesystem is a journaling file system that is commonly used by the Linux operating system. It is the default file system for many popular Linux distributions....
 filesystem.

FreeBSD
FreeBSD

FreeBSD is a Unix-like free software operating system descended from AT&T Unix via the Berkeley Software Distribution branch through the 386BSD and Berkeley Software Distribution#4.4BSD and descendants operating systems....
 supports POSIX.1e ACLs. There is experimental support for NFSv4 ACLs for UFS
UFS

UFS may refer to:* Unix File System, a file system used by many Unix and Unix-like operating systems* United Feature Syndicate, commonly known as United Media...
 and ZFS
ZFS

In computing, ZFS is a file system designed by Sun Microsystems for the Solaris Operating System. The features of ZFS include support for high storage capacities, integration of the concepts of filesystem and volume , Snapshot and copy-on-write clones, continuous integrity checking and automatic repair, RAID-Z and native NFSv4 ACLs....
 filesystems.

Traditional Unix permissions

Permissions on Unix-like
Unix-like

A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
 systems are managed in three distinct classes. These classes are known as user, group, and others. In effect, Unix permissions are a simplified form of access control list
Access control list

With respect to a computer filesystem, an access control list is a list of permissions attached to an object. The list specifies who or what is allowed to access the object and what operations are allowed to be performed on the object....
s (ACLs).

When a new file is created on a Unix-like system, its permissions are determined from the umask
Umask

umask is a Command and a Function in POSIX environments which sets the default permission modes for newly created files and directories of the current process....
 of the process that created it.

Classes

On Unix file system
File system

In computing, a file system is a method for store and organize computer files and the data they contain to make it easy to find and access them....
s, every file
Computer file

A computer file is a block of arbitrary information, or resource for storing information, which is available to a computer program and is usually based on some kind of durable computer storage....
 and directory
Directory (file systems)

In computing, a directory, folder, catalog, or drawer is a virtual container within a digital file system, in which groups of files and other directories can be kept and organized....
 is owned by a specific user. The owner of an object comprises its user class. Permissions assigned to the user class only apply to that specific user.

A file or directory is also assigned a group, which comprises its group class. Permissions assigned to the group class only apply to members of that group (other than the owner). It is not necessary that the owner be a member of the file's group. While a particular file can be assigned to only one group, a particular user can be a member of any number of groups, and a group can include any number of users. The "groups" command lists all the groups that include a user; the "members" command lists all the users that are the member of a particular group (Stutz 2004). The system administrator uses "addgroup" to add a user to a group.

Users who are not otherwise represented by the other two classes comprise a file's others class.

The effective permissions that have applied to a specific user in relation to a file are determined in logical precedence. For example, the user who owns the file will have the effective permissions given to the user class regardless of those assigned to the group or others class.

Basic Permissions

There are three specific permissions on Unix-like
Unix-like

A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
 systems that apply to each class:
  • The read permission, which grants the ability to read a file. When set for a directory, this permission grants the ability to read the names of files in the directory (but not to find out any further information about them, including file type, size, ownership, permissions, etc.)
  • The write permission, which grants the ability to modify a file. When set for a directory, this permission grants the ability to modify entries in the directory. This includes creating files, deleting files, and renaming files.
  • The execute permission, which grants the ability to execute a file. This permission must be set for executable binaries (for example, a compiled c++ program) or shell scripts (for example, a Perl program) in order to allow the operating system to run them. When set for a directory, this permission grants the ability to traverse its tree in order to access files or subdirectories, but not see files inside the directory (unless read is set).


The effect of setting the permissions on a directory (rather than a file) is "one of the most frequently misunderstood file permission issues" (Hatch 2003).

When a permission is not set, the rights it would grant are denied. Unlike ACL
Access control list

With respect to a computer filesystem, an access control list is a list of permissions attached to an object. The list specifies who or what is allowed to access the object and what operations are allowed to be performed on the object....
-based systems, permissions on a Unix-like system are not inherited. Files created within a directory will not necessarily have the same permissions as that directory. The permissions to be assigned are determined using umask
Umask

umask is a Command and a Function in POSIX environments which sets the default permission modes for newly created files and directories of the current process....
s.

Additional Permissions

Unix-like
Unix-like

A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
 systems typically employ three additional permissions or modes. These special permissions are set for a file or directory overall, not by a class.
  • The set user ID
    Setuid

    setuid and setgid are Unix access rights flags that allow users to run an executable with the permissions of the executable's owner or group....
    , setuid, or SUID permission. When a file for which this permission has been set is executed, the resulting process will assume the effective user ID
    User identifier (Unix)

    On Unix-like operating systems, users are identified within the kernel by an unsigned integer value called a user identifier, often abbreviated to UID or User ID....
     given to the user class.
  • The set group ID, setgid, or SGID permission. When a file for which this permission has been set is executed, the resulting process will assume the group ID
    Group identifier (Unix)

    In Unix-like systems, multiple users can be categorized into Group . POSIX and conventional Unix file system permissions are organized into three classes, user, group, and others....
     given to the group class. When setgid is applied to a directory, new files and directories created under that directory will inherit the group from that directory. (Default behaviour is to use the primary group of the effective user when setting the group of new files and directories.)
  • The sticky
    Sticky bit

    The sticky bit is an access-right Flag that can be assigned to Computer file and directory on Unix systems....
     permission. The typical behaviour of the sticky bit on executable files encourages the kernel to retain the resulting process image beyond termination. 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.


These additional permissions are also referred to as setuid bit, setgid bit, and sticky bit respectively, due to the fact that they each occupy only one bit.

Notation of traditional Unix permissions


Symbolic notation

There are many ways by which Unix permission schemes are represented. The most common form is symbolic notation. This scheme represents permissions as a series of 10 characters.

First Character
-a regular file
da directory
Directory (file systems)

In computing, a directory, folder, catalog, or drawer is a virtual container within a digital file system, in which groups of files and other directories can be kept and organized....
l a symbolic link
Three groups of three
firstwhat the owner can do
secondwhat the group members can do
thirdwhat other users can do
The triplet
firstr: readable.
secondw: writable.
thirdx: executable.
other: see below.


The first character indicates the file type
Unix file types

For normal files in the file system, Unix does not impose or provide any internal file structure.This implies that from the point of view of the operating system, there is only one file type....
:
  • - denotes a regular file
  • d denotes a directory
    Directory (file systems)

    In computing, a directory, folder, catalog, or drawer is a virtual container within a digital file system, in which groups of files and other directories can be kept and organized....
  • b denotes a block special file
  • c denotes a character special file
  • l denotes a symbolic link
    Symbolic link

    In computing, a symbolic link is a special type of computer file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution....
  • p denotes a named pipe
    Named pipe

    In computing, a named pipe is an extension to the traditional pipeline concept on Unix and Unix-like systems, and is one of the methods of inter-process communication....
  • s denotes a domain socket
    Unix domain socket

    A Unix domain socket or IPC socket is a data communications endpoint that is similar to an Internet socket, but does not use a network protocol for communication....


Each class of permissions is represented by three characters. The first set of characters represents the user class. The second set represents the group class. The third and final set of three characters represents the others class.

Each of the three characters represent the read, write, and execute permissions respectively:
  • r if the read bit is set, - if it is not.
  • w if the write bit is set, - if it is not.
  • x if the execute bit is set, - if it is not.
  • The x will be an s if the setuid or setgid bit is also set, and in the third, it will be a t if the sticky bit
    Sticky bit

    The sticky bit is an access-right Flag that can be assigned to Computer file and directory on Unix systems....
     is set. If these are set but the execute bit is not, the letter will be in uppercase.


The following are some examples of symbolic notation:
  • -rwxr-xr-x for a regular file whose user class has full permissions and whose group and others classes have only the read and execute permissions.
  • crw-rw-r-- for a character special file whose user and group classes have the read and write permissions and whose others class has only the read permission.
  • dr-x------ for a directory whose user class has read and execute permissions and whose group and others classes have no permissions.


Symbolic notation and additional permission

The three additional permissions are indicated by changing one of the three "execute" characters as shown in the following table:
PermissionClassExecutable1Non-executable2
Set User ID
Setuid

setuid and setgid are Unix access rights flags that allow users to run an executable with the permissions of the executable's owner or group....
 (setuid)
UsersS
Set Group ID (setgid)GroupsS
Sticky bit
Sticky bit

The sticky bit is an access-right Flag that can be assigned to Computer file and directory on Unix systems....
OtherstT
  1. The character that will be used to indicate that the execute bit is also set.
  2. The character that will be used when the execute bit is not set.


Here is an example:
  • "-rwsr-Sr-x" for a file whose user class has read, write and execute permissions; whose group class has read permission; whose others class has read and execute permissions; and which has setuid
    Setuid

    setuid and setgid are Unix access rights flags that allow users to run an executable with the permissions of the executable's owner or group....
     and setgid permissions set.


Octal notation

Another common method for representing Unix permissions is octal
Octal

The octal numeral system, or oct for short, is the radix-8 number system, and uses the digits 0 to 7. Numerals can be made from Binary numeral system numerals by grouping consecutive digits into groups of three ....
 notation
. Octal notation consists of a three- or four-digit base-8 value.

With three-digit octal notation, each numeral represents a different component of the permission set: user class, group class, and "others" class respectively.

Each of these digits is the sum of its component bits (see also Binary numeral system
Binary numeral system

The binary numeral system, or notation with a radix of 2. Owing to its straightforward implementation in digital electronic circuitry using logic gates, the binary system is used internally by all modern computers....
). As a result, specific bits add to the sum as it is represented by a numeral:
  • The read bit adds 4 to its total (in binary 100),
  • The write bit adds 2 to its total (in binary 010), and
  • The execute bit adds 1 to its total (in binary 001).
These values never produce ambiguous combinations; each sum represents a specific set of permissions.

These are the examples from the Symbolic notation section given in octal notation:
  • "-rwxr-xr-x" would be represented as 755 in three-digit octal.
  • "-rw-rw-r--" would be represented as 664 in three-digit octal.
  • "-r-x------" would be represented as 500 in three-digit octal.


Here is a summary of the meanings for individual octal digit values:

0 --- no permission 1 --x execute 2 -w- write 3 -wx write and execute 4 r-- read 5 r-x read and execute 6 rw- read and write 7 rwx read, write and execute

Octal digit values can be added together to make Symbolic Notations:
(4=r)+(1=x)

(5=r-x)
(4=r)+(2=w)

(6=rw-)
(4=r)+(2=w)+(1=x)

(7=rwx)

Here is a summary showing which octal digits affect permissions for user, group, and other:
  • UGO = User, Group, Other
  • 777 = "-rwxrwxrwx" = rwx for all
  • 754 = "-rwxr-xr--" = rwx for owner, r-x for group, r-- for other
  • 124 = "---x-w-r--" = x for owner, w for group, r for other


Octal notation and additional permissions

There is also a four-digit form of octal notation. In this scheme, the standard three digits described above become the last three digits. The first digit represents the additional permissions. On some systems, this first digit cannot be omitted; it is therefore common to use all four digits (where the first digit is zero).

This first digit is also the sum of component bits:
  • The setuid bit adds 4 to the total,
  • The setgid bit adds 2 to the total, and
  • The sticky bit adds 1 to the total.


The example from the Symbolic notation and additional permissions section, "-rwsr-Sr-x" would be represented as 6745 in four-digit octal. In addition, the examples in the previous section (755, 664, and 500) would be represented as 0755, 0664, and 0500 respectively in four-digit octal notation.

User private group

Some systems create a new group – a "user private group" – for each new user. The "user private group" scheme can be preferred for a variety of reasons including using a umask of 002 and not having every "user" able to write to newly created files.

See also

  • Access control list
    Access control list

    With respect to a computer filesystem, an access control list is a list of permissions attached to an object. The list specifies who or what is allowed to access the object and what operations are allowed to be performed on the object....
  • chattr
    Chattr

    chattr is a Linux command that allows a user to set certain File attribute on a file. Mostly chattr is used to make files immutable so that password files and certain system files cannot be erased during software upgrades....
  • chmod
    Chmod

    The chmod command is a UNIX shell command in Unix and Unix-like environments. When executed, the command can change file system modes of Computer file and directory ....
    , the command used to set permissions on Unix-like systems
  • File system
    File system

    In computing, a file system is a method for store and organize computer files and the data they contain to make it easy to find and access them....
  • Group identifier (Unix)
    Group identifier (Unix)

    In Unix-like systems, multiple users can be categorized into Group . POSIX and conventional Unix file system permissions are organized into three classes, user, group, and others....
  • lsattr
    Lsattr

    lsattr is a command line program for listing the attributes on a Linux second extended file system . It is also a command to display attributes of devices on an AIX operating system....
  • POSIX
    POSIX

    POSIX or "Portable Operating System Interface" is the collective name of a family of related standardizations specified by the Institute of Electrical and Electronics Engineers to define the application programming interface , along with shell and utilities interfaces for software compatible with variants of the Unix operating system, altho...
  • User identifier (Unix)
    User identifier (Unix)

    On Unix-like operating systems, users are identified within the kernel by an unsigned integer value called a user identifier, often abbreviated to UID or User ID....


External links

  • by Brian Hatch 2003.
  • by Brian Hatch 2003.
  • by Michael Stutz 2004