You can set read, write and execute permissions on files and folders in Linux. You can apply these permissions to owner, group and those who are neither owner nor group member.
In the above screenshot you can see the highlighted section as drwxr-xr-x. The first character, d, simply implies that it's a directory where for files it should be -. The latter 9 characters are those that defines the permission for the folder.
The first 3 of the 9 characters are permissions for the user, the following 3 for the group and followed by for other users, represented by r (read), w (write), x (execute) and - (no permission). The assigned user and group for the directory is both root.
The above example's permission could then be defined as the followings;
Each category is can be represented by a single letter (u, g, o). Octal notation is a way of representing the permission in binary and to then total up the number. r-x for example is 1*(2^2) + 0*(2^1) + 1*(2^0), which results in 5. Here's a table for easier illustration;
|7||111||read, write, execute|
With that out of the way, you can start configuring permission for your files and folders.
There are other methods and layers of file and folder permissions in Linux such as ACL, SELinux and AppArmor but is not covered here.
$ stat -c "%a : %A" /var/www/html/index.html 644 : -rw-r--r--
$ sudo chmod g+w /var/www/html/index.html [sudo] password for user:
$ sudo chmod o-r /var/www/html/index.html
$ sudo chmod u=rx /var/www/html/index.html
$ stat -c "%a : %A" /var/www/html/index.html 560 : -r-xrw----
$ sudo chmod 560 /var/www/html/*
$ sudo chmod -R 560 /var/www/html/
$ sudo ls -l /var/www/html/ total 20 dr-xrw---- 2 root root 4096 Jan 24 09:58 css -r-xrw---- 1 root root 10918 Jan 23 19:57 index.html dr-xrw---- 2 root root 4096 Jan 24 09:57 js
Comment anonymously. Login not required.