Permissions · Lesson 1 of 8
File Permissions
0 / 4 checkpoints answered
Linux represents many resources through file-like interfaces, and each filesystem object has metadata that controls access. Reading that metadata is a foundation for working safely with files and directories.
Reading a Long Listing
Use ls -l to display a long listing:
$ ls -ld Desktop/
drwxr-xr-x 2 pete penguins 4096 Dec 1 11:45 Desktop/
The first field, drwxr-xr-x, combines one file-type character with nine permission characters. The listing also identifies pete as the owner and penguins as the group associated with the directory.
The initial character describes the object type. Common values include:
-for a regular filedfor a directorylfor a symbolic link
Other special file types also exist. The remaining nine characters are the access permissions:
d | rwx | r-x | r-x
CheckIn drwxr-xr-x, what does the first d indicate?
press 1/2/3 to answer · → next lesson
Understanding r, w, and x
Each permission triplet uses these characters:
rgrants read permission.wgrants write permission.xgrants execute permission.-means that permission is absent.
For a regular file, read permits access to its contents, write permits modification of its contents, and execute permits the kernel to attempt to run it as a program. Execution can still fail if the file format, interpreter line, mount options, or another security control does not allow it.
For a directory, the meanings concern directory entries:
- Read permits listing names in the directory.
- Write permits creating or removing entries, normally in combination with execute permission.
- Execute, also called search permission, permits traversing the directory and accessing entries by name.
Deleting a file is governed primarily by permissions on its parent directory, not by the file's own write bit.
CheckWhat does execute permission on a directory primarily allow?
press 1/2/3 to answer · → next lesson
Owner, Group, and Other Classes
The nine mode characters form three triplets in a fixed order:
- Owner: permissions used when the process's effective user ID matches the file owner.
- Group: permissions used when an applicable process group ID matches the file's group.
- Other: permissions used when neither of the preceding classes matches.
The kernel selects one applicable class; it does not combine the three triplets to find the most permissive result. Additional mechanisms such as access control lists, mount options, capabilities, or mandatory access controls can further affect the final decision.
In the example, the owner triplet is rwx, while both group and other are r-x. The owner can read, write, and search the directory. The group and other classes can read and search it but cannot create or remove entries through the directory's ordinary mode bits.
CheckAfter the file-type character, in what order do the three permission triplets appear?
press 1/2/3 to answer · → next lesson
CheckWhat ordinary permissions does the group class have in drwxr-xr-x?
press 1/2/3 to answer · → next lesson
To reinforce these concepts in an isolated environment, try the Linux User Group and File Permissions lab. It provides practice reading modes and changing ownership and permissions.
Summary
You can now interpret the basic permission field in a Linux long listing.
- Separate the file-type character from the nine permission bits.
- Read
r,w, andxaccording to whether the object is a file or directory. - Divide the mode into owner, group, and other triplets.
- Relate the triplets to the owner and group shown by
ls -l.
Lesson complete
You finished File Permissions. Nice work — keep the momentum going.