Permissions¶
Parts of the Permission String¶
There are 4 parts in the permission string.
It may look something like this:
The permission string can be broken down into these 4 parts:
-
The first character indicates the type of file. (
-)
The next nine characters represent the permissions for users, broken up into 3 characters for each permission. -
user (owner) - (
rwx) - group - (
r-x) - others - (
r-x)
File Type Indicator Bit (first bit)¶
The first character in the permission string indicates the type of file:
-: Regular file.d: Directory.l: Symbolic link.c: Character device file (special file that represents a device).b: Block device file (special file that represents a device such as a hard disk).s: Socket (used for IPC - inter-process communication).p: Named pipe (FIFO).
Permission Bits¶
The next nine characters are in three sets of three characters, each set representing the permissions for the user (owner), group, and others:
-
r: Read permission.- For a file, this means the contents of the file can be read.
- For a directory, this means the contents of the directory can be listed.
-
w: Write permission.- For a file, this means the contents of the file can be modified.
- For a directory, this means files can be created, deleted, or renamed within the directory.
-
x: Execute permission.- For a file, this means the file can be executed (if it's a program or a script).
- For a directory, this means the ability to access the directory's contents.
The three sets are:
- User (Owner) Permissions: The first set of three characters after the file type.
- Group Permissions: The second set of three characters.
- Others Permissions: The third set of three characters.
Special Permission Bits¶
In addition to r, w, and x, there are a few special permissions:
-
s: Setuid/Setgid.- Appears in the
userorgrouppermission field instead of thex. - If set on a file, the file will execute with the permissions of the file owner or group.
- Appears in the
-
t: Sticky bit.- Appears in the
otherspermission field. - Often used on directories, like
/tmp. - Indicates that only the file owner (or root) can delete or rename files in the directory.
- Appears in the
-
-: Means the absence of a permission.- The
-in a field means that the corresponding set of users does not have that permission.
- The