Hope this will help you to understand different file permissions and how to changes the permission of a file or directory in a UNIX/LINUX system.
chmod [numeric combination] [filename]
here [numeric combination] is created using the following criteria.
(User who owns the file.)
(Group that owns the file)
if you want to make your file read only by owner, then use
chmod 400 filename
if only executed by others
chmod 001 filename
if read/write by the owner and only read by everyone else
chmod (4+2)(4)(4) file
chmod 644 filename
With this if all need executable rights
chmod (4+2+1)(4+1)(4+1) file
chmod 755 filename
This can also be calculated in a more professional way.
when we are checking the permissions of files using “ls -l” command in the terminal we get a results which looks like “– rwx r-x r– file “.
this can be interpreted as;
- rwx r-x r-- file--111 101 100
Where now when we convert each set binary digits to decimal,
We get the numeric values we wonted. In this case its 754
So we have to use the command.
chmod 754 file