Recent Posts

ads

Linux File Permission





File systems use permissions and attributes to regulate the level of interaction that system processes can have with files and directories. 


The breakdown of permissions looks like this:
  • u – user
  • g – group
  • o – other
The 'other' entry is the dangerous one, as it effectively gives everyone permission for the folder/file. The permissions you can give to a file or folder are:
  • r – read
  • w – write
  • x – execute

Use the ls command's -l option to view the permissions 




The first column is what we must focus on. Taking an example value of drwxrwxrwx+, the meaning of each character is explained in the following tables:




It goes like this:R(Read) , W ( Write), X (Execute)

Now check the colored columns:
  1. The owner 
  2. The owner group
  3. The other users
In the first column, you will see that mostly the owner has read, write and execute permission 
The second one, the group can execute and read most of the time.
The third one they can execute most of the time. But maybe you want to change that.



Maybe you want to go to "Desktop"and check the permissions


We can see that user ohhhvictor have read and write rights, the group has read writes and the others doesn't have any


The chmod command lets you change the access permissions of files and folders. The chmod command, like other commands, can be executed from the command line or through a script file.

Below is a list of several numerical permissions that can be set for the user, group, and everyone else on the computer. Next to the number is the read/write/execute letter equivalent.
  • 7, rwx, read, write, and execute
  • 6, rw-, read and write
  • 5, r-x, read and execute
  • 4, r--, read-only
  • 3, -wx, write and execute
  • 2, -w-, write only
  • 1, --x, execute only
  • 0, ---, none
Most of the time you will be dealing with 7, 6 , 4 ,0 most of the times

So for example in a condition that we have the command chmod 640 means that owner can read and write , the group have read only rights and the rest nothing



You can change this file one more time..


Command line: File permissions

The commands for modifying file permissions and ownership are:

  • chmod – change permissions
  • chown – change ownership.
Neither command is difficult to use. It is important, however, that you understand the only user that can actually modify the permissions or ownership of a file is either the current owner or the root user. So, if you are user Peter, you cannot make changes to files and folders owned by Jane without the help of root (or sudo).
Now let's check how to change ownership..

The chown command is used to change the owner and group of files, directories and links. 

For example, the following would transfer the ownership of a file named mymessage.txt and a directory named   MyGreatDirectoy  to a new owner named Jane:

chown jane  mymessage.txt MyGreatDirectory

Thus, for example, the following would change the owner of a file named anewoutput.txt to the user with the user name Peter and change its group to group2:

chown Peter:group2 anewoutput.txt
If you want to do that automatically you will need binary notation

You can then convert these binary numbers:
000=0     100=4
001=1     101=5
010=2     110=6
011=3     111=7

After this we go to UMASK
The umask setting (usually established in a shell startup file such as ~/.profile) is used to limit the permissions that will be assigned to any file you create. It’s a bit confusing because it sort of works ‘upside down’ – the permission bits that are set in umask will be withheld from any files you create. 



Umask is a reverse file permission table, but it's define what you take away..so for example :umask 022
0 we don't take away anything, 2, and 2  means that the Group and the others have "read and execute "rights..


So, in this lesson , you learn how to change permissions, change ownership and the concept of Binary Notation.If you understood it, and was useful, please click like.
Thank you in advance
Linux File Permission Linux File Permission Reviewed by ohhhvictor on August 13, 2018 Rating: 5

No comments:

Facebook

ads
Powered by Blogger.