Ubuntu Reference Guide

part of the WillPowered Inc. network
© 2011 William Hall <5/> - This site uses HTML5


Using the chmod command and setting samba settings involves setting permissions. This is done using three digits to express the various permissions for files and directories. Using the ls command will display the permissions textually.

Each of these groups involves information for reading, writing and executing. Firstly, these are expressed with binary, 100 for reading only, 110 for reading and writing etc. The binary values for each permission configuration are converted to decimal for use with chmod and samba.


Use the above table to calculate the decimal value for the permission, placing the 0's and 1's where the x's are. Then calculate the total using the column headers above the 1's. For example, reading only (100) equals 4, no access equals 0.

Using ls -l, the permissions are displayed in a string of ten characters with the last nine being permission settings. The letters are rwx (r for read, w for write, x for execute) repeated three times, once for each group (from above). If any permissions are not applied then the character is replaced with a -.

Putting this all together, if you wanted a directory (and its files) to be completely editable by the owner, readable by the group and innaccessible by everyone else then you would use the following command.

$ chmod -R 750 /directory

If you were applying permissions to a file instead of a directory, don't use -R. If you were not the owner you would have to use sudo or the following (omitting -R for an individual file).

$ chown -R user:group /directory

Checking permissions of a file using ls -l will display the following.

$ ls -l /file -rwxr-w--- 1 user group 508063 year time file

The first - is replaced by d if the file is a directory and l if the file is a link and the links destination is displayed at the end after =>.