Unix file permissions and chmod explained in 5 minutes

, 3 min read

In Unix-based systems, files and directories have access permissions.

If you open a terminal and run:

ls -l

You will get something like: file-permissions-explained

  1. drwx------: file type and permissions. d indicates that it is a directory. The following nine characters represent the permissions for the file or directory. In this example, rwx------ indicates that the owner of the directory (aristot) has read, write, and execute permissions, while others have no permissions.

  2. 3: number of links to the file or directory. In this case, the directory Applications has three links associated with it.

  3. aristot: owner of the file or directory.

  4. staff: group associated with the file or directory.

  5. 96: file size in bytes. For directories, the size generally represents the amount of disk space used by the directory’s metadata.

  6. Feb 15 10:20: date and time of the last modification to the file or directory.

  7. Applications: name of the file or directory.

More about file permissions permissions:

  • d: directory. Files don’t have this.
  • r: read
  • w: write
  • x: execute

The reason there are 9 characters apart from d, is that each file/directory has permissions on three levels:

  • user: file owner
  • group: members of file’s group
  • others: everyone else


  • rwx------: file owner can read, write and execute the file, and everyone else can do nothing.
  • r-xr-x--x: file owner and group can read and execute. Everyone else can only execute.

Each permission is associated with a number: r: 4, w: 2, x: 1. This results in a unique sum for each permission set:

  • rwx: 4+2+1 = 7
  • rw-: 4+2 = 6
  • r-x: 4+1 = 5
  • -wx: 2+1 = 3

chmod is just a command-line tool that allows you to change permissions:

  • chmod 755 /some/file sets the permissions to rwx for owner and r-x for group and others.
  • chmod +x /some/file adds execute permission to all.
  • chmod -w /some/file removes write permission from all.
#tech-blog, #unix