File and Folder Permissions

This page contains information on the series of letters and dashes that define file and folder permissions in Linux.

Consider the following terminal output when running ls -l

-rw-r--r-- 1 root root       3028 Apr 23 02:40 adduser.conf
drwxr-xr-x 2 root root       4096 Apr 23 03:17 alternatives
drwxr-xr-x 3 root root       4096 Jun 28 21:20 apparmor
drwxr-xr-x 7 root root       4096 Jun 28 21:20 apparmor.d
drwxr-xr-x 3 root root       4096 Jun 28 21:20 apport
drwxr-xr-x 7 root root       4096 Apr 23 02:40 apt
-rw-r----- 1 root daemon      144 Nov 12  2018 at.deny
-rw-r--r-- 1 root root       2319 Feb 25  2020 bash.bashrc
-rw-r--r-- 1 root root         45 Jan 25  2020 bash_completion

The first character denotes the file type. For examples, the first character in each list is either a dash -, the letter d, or an l.

  • A dash - indicates that the file is a regular file.

  • The letter d indicates a directory file type, which is commonly referred to as a folder. A directory is a type of special file. Instead of data, it contains pointers to all of the files that are contained within the directory.

  • A symlink begins with a lowercase L, e.g.,

lrwxrwxrwx 1 root root      4 Dec 30 05:15 sh -> bash

Permissions Abbreviations

Permissions for files are represented by the letters r, w and x or a hyphen - character.

  • r if reading permitted, - if it is not.

  • w if writing permitted, - if it is not.

  • x if execution permitted, - if it is not.

Symbolic Notation Triads

The first triad is composed of the second, third and fourth characters after the file type. This show what the owner can do.

The second triad or next three characters show the permissions for the group members.

The third triad or last three characters show the permissions for the other users.

In each triad, the first character is read permissions, the second character is write permissions and the third character is execute permissions.

Numeric Notation

Another method for representing permissions is an octal (base-8) notation that consists of at least three digits.

Examples of symbolic and numeric notation

Symbolic Numeric Description
---------- 0000 no permissions
-rwx------ 0700 read, write, & execute only for owner
-rwxrwx--- 0770 read, write, & execute for owner and group
-rwxrwxrwx 0777 read, write, & execute for owner, group and others
---x--x--x 0111 execute
--w--w--w- 0222 write
--wx-wx-wx 0333 write & execute
-r--r--r-- 0444 read
-r-xr-xr-x 0555 read & execute
-rw-rw-rw- 0666 read & write
-rwxr----- 0740 owner can read, write, & execute; group can only read; others have no permissions

Numbers for all permission types

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


comments powered by Disqus