The umask command can be used to read or set default file permissions for the current user. The umask value is subtracted from the default permissions (666) to give the final permission.
666 : Default permission
022 : - umask value
644 : final permission
The output below explains what permissions the the numbers represent.
Owner
|
Group |
World |
Permission |
7 (u+rwx) | 7 (g+rwx) | 7 (o+rwx) | read + write + execute |
6 (u+rw) |
6 (g+rw) | 6 (o+rw) | read + write |
5 (u+rx) | 5 (g+rx) | 5 (o+rx) | read + execute |
4 (u+r) | 4 (g+r) | 4 (o+r) | read only |
2 (u+w) | 2 (g+w) | 2 (o+w) | write only |
1 (u+x) | 1 (g+x) | 1 (o+x) | execute only |
Character equivalents can be used in the chmod command.
root> chmod o+rwx *.log
root> chmod g+r *.log
root> chmod -Rx *.log
Different users in the operating system have ownership and permission to ensure that the files are secure and put restrictions on who can modify the contents of the files. In Linux there are different users who use the system:
-
Each user has some properties associated with them, such as a user ID and a home directory. We can add users into a group to make the process of managing users easier.
-
A group can have zero or more users. A specified user can be associated with a “default group”. It can also be a member of other groups on the system as well.
To change owner of the file
In our case we have files as follows:
Now if I use my.file in my case, to change ownership I will use the following syntax:
chown prdc my.file
where the prdc is another user in the system
The "-R" flag causes the command go recurse through any sub directories and can be used as following for a folder
Comments
0 comments
Please sign in to leave a comment.