Use ls -l to learn the permissions on a file.
When you type ls -l on a file, you’ll see the file’s permissions represented in the first column. For example:
% ls -l ch01
-rw-r---- 1 lmui 68608 Oct 18 13:11 ch01The first column of this listing is a 10-character string consisting of dashes and the characters r, w, and x. This string represents the permissions for each file. To interpret the permissions, you need to break up this string into four distinct parts.
The first character tells you what kind of file this is, and doesn’t have much to do with file permissions. When it’s a -, it means that the file is a regular file. Other values are d for a directory and l for a symbolic link.
You can ignore the first character for now. The remaining nine characters represent who has read, write, or execute permission for the file. Think of it as consisting of three sets each of the characters r, w, x, and -. The first set represents owner permission, the second set represents group permission, and the third set represents permissions for everyone else (aka “the world”).
An r represents read permission, w represents write permission, and x represents execute permission. For each set, the three characters rwx always appear in order. If any of these characters is missing (i.e., replaced by a dash), then that permission is denied.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access