Hi folks
Many guys here are well vexed with file permissions and how to chmod files, but I had always wondered what it was until I did a little read up on Google, and this is what I got
For those who don’t understand why it’s always been said chmod 777/755/644….etc.
May be you will appreciate them after reading this tutorial
Let’s start
In Unix/Linux whenever you check the property of any file, under the permissions tab, there are 3 categories of users of the file
• Owner (the owner of the file and by default has read and write permissions)
• Group (Any group the owner might belong and by default has read permissions)
• Others (Other users on the operating system, and by default have read only permissions)
Display More
PERMISSIONS EXPLAINED
[COLOR='#FF0000']Read permission[/COLOR]: The user can only open the file to see the content without being able to modify the content of the file.
[COLOR='#FFA500']Write permissio[/COLOR]n: The user can open the file with a text editor and change/modify the contents by deleting, adding and saving the new settings.
[COLOR='#00FF00']Execute permission[/COLOR]: which gives the user the right to run the file as a program. Execute the file as a program if it’s a binary file or a shell script
Display More
All the file permissions read, write, execute have certain numeric values associated with them
Read has a numeric value of [COLOR='#FF0000']4[/COLOR]
Write has a numeric value of [COLOR='#FFA500']2[/COLOR]
Execute has a numeric value of [COLOR='#00FF00']1[/COLOR]
Display More
QuoteWhich means that at best a file can have a numeric value of 7, which is 4+2+1=7
So a file created in Unix/Linux by default has
Owner -read and write permission which is 4+2=6
Group -read permission which is 4
Others -read permission which is 4
Display More
QuoteSo by default any file created in Linux has 644 permission
UMASK
Umask is a system variable in Linux, when you type umask in the terminal you get a value 0022
But we consider the value 022.Now when a file is created what Linux does is that it subtracts the value of umask from 666 for a file and 777 for a directory, so by default a file has 644 permissions and a directory has 755 permissions.
HOW TO CHMOD IN TERMINAL
Change directory or cd to the directory where the file is located
e.g.
Quotecd /usr/bin/
Now let’s assume you file is called kingjj
So we can change permissions to 644 by typing
Quotechmod 644 kingjj
Or simply type
Quotechmod 644 /usr/bin/kingjj