Every Linux file and directory has an owner. Each file or directory also belongs to a group. The permissions which can be assigned to a file are read, write and eXecute. These permissions are assigned separately for the file owner, members of the group to which the file belongs and finally for everyone else.
File permissions are generally shown in one of two formats on Linux. The first is a string of letters. For example:
drwxrwxrwx -rwxrw-r--
The second way of indicating the same information is a shorthand 3 digit number. The following table explains how the values are determined.
| Owner | Group | Other | |
|---|---|---|---|
| permission | r w x | r w x | r w x |
| value | 4 2 1 | 4 2 1 | 4 2 1 |
Sum for each set and concatenate. Thus all permissions for everyone would be 7 & 7 & 7 or 777
Change permissions from console using sudo1)
sudo chmod [-R] 777 [dir or file name(s)]
-R implies recursively setting for all sub directories at or under given.
Change owner and group with chown
sudo chown [-R] owner:group files
To change just files, not directories
sudo find . -type f -exec [chmod or chown] [settings] {} \;
for only directories use ”-type f” instead of ”-type d”
Example: change all directories permissions to 755:
sudo find . -type d -exec chmod 755 {} \;
| Up one level |
|---|