=====================
= THE CHMOD COMMAND =
=====================
First here are few things you need to know:
-----------------------------------------------
- File Ownerships
(u)ser , (g)roup , (o)thers
- File Permissions
(r)ead , (w)rite , e(x)ecute
- View Permissions with ls command
EXAMPLE: ls -l [PRESS ENTER]
-rwxr-xr-- 2 iclunk nobody 512 Dec 8 12:40 sdf-noob.txt
-rw------- 2 iclunk nobody 512 Jun 12 12:34 newfile.txt
- Permissions Breakdown
(u)ser (g)roup (o)thers
-rw- xr- xr- 2 iclunk nobody 512 Dec 8 12:40 sdf-noob.txt
1)First section is permissions for user
2)Second section is for group
3)Third section is for others
-NOTE:
The d at the beginning of the line stands for directory.
drwxr-xr-- 2 iclunk nobody 512 Dec 8 12:40 articles
drwxr-xr-- 2 iclunk nobody 512 Jul 14 18:31 bin
drwxr-xr-- 2 iclunk nobody 512 Dec 8 12:52 books
Examples of CHMOD command:
-----------------------------------------------
$chmod g+w sdf-noob.txt [PRESS ENTER]
$ls -l [PRESS ENTER]
-rw------- 2 iclunk nobody 512 Jun 12 12:34 newfile.txt
-rwxrwxr-- 2 iclunk nobody 512 Dec 8 12:40 sdf-noob.txt
[Gives the group (w)rite permission to the sdf-noob.txt file]
$chmod u+x,g+rx,o+r newfile.txt
$ls -l [PRESS ENTER]
-rwxr-xr-- 2 iclunk nobody 512 Jun 12 12:34 newfile.txt
[The above is a good example for gopher file permissions]
$chmod u-wx articles [PRESS ENTER]
$ls -l {PRESS ENTER]
dr--r-xr-- 2 iclunk nobody 512 Dec 8 12:40 articles
drwxr-xr-- 2 iclunk nobody 512 Jul 14 18:31 bin
drwxr-xr-- 2 iclunk nobody 512 Dec 8 12:52 books
[Removes the (w)rite and e(x)ecute permissions from the articles directory]
---------------------------------
Another great document by iclunk.
References:
https://www.freecodecamp.org/news/linux-chmod-chown-change-file-permissions/