Monday, July 8, 2013

Umask - User Mask

New files should not be created with 666! To avoid this problem a
permission mask exists. It is obviously important to know with what permissions new files and directories are created. Under Linux, it’s not really easy to tell, since the default permissions can be modified by setting a umask (with the umask command).
If no umask were set (which never happens, by the way), a file would always be created with permissions 666 (rw-rw-rw-) and a directory would get 777(rwxrwxrwx). In actual practice however, a umask is set, and this number is subtracted from these permissions. 
So, with a umask of 022, the default permissions for a file will become 644 (rw-r--r--, 666-022) and the default permissions for a directory will become 755(rwx-r-xr-x, 777-022).
The default umask depends on your distribution, and whether your
distribution uses something called “User Private Groups”.

• Red Hat assigns a umask of 002 to regular users, and 022 to root.
• SUSE assigns a umask of 022 to all users, including root.
- What is your current default permission (umask)
- How do you set your default permission?
- Umask defines what permissions, in octal, cannot be set
- Umask stands for user file creation mode mask
- In essence, system sets the default permission on the file and directory
- If i would have no "umask:, the default permission on the file would be "777"
- Usually set in a login script
- it is the inverse of the normal octal permissions
- "umask -S" shows your umask in symbolic form
- linux removes the "x" permissions (or the 1) so 777 is the same as 666
- here are the common umask values:
--> 000 = full access (r+w) to everyone, or 666
--> 006 = no access to other, or 660
--> 022 = full access (r+w) to user and r to g and 0, or 644
--> 066 = full access (r+w) to user and no access to g + o, or 600 - Normally, you can subtract from 666 but be very careful as it may be 777.
In Fedora Linux, it is 666 but lets test it out...

--> View the current umask setting

$umask

--> shows your umask in symbolic form

$ umask -S

- Umask on directory should be subtract from 777
  
  777
- 022
------
  755

System-wide umask for all users in /etc/profile
Individual umask in $HOME/.bash_profile or $HOME/.profile
Default value of umask is:
For root 022
For user 002 (if user private groups are used) or 022 (otherwise)
The umask specifies what permission bits will be set on a new file when it is created. The umask is an octal number that specifies the which of the permission bits will not be set. 

On Task 


change Symbolic way
1.Give 704 to abc file
2.Give 417 to abc file
3.Give 006 to abc file
4.give 707 to abc file

II
change Octal way
1.change to octal mode r-xrw-r-x to abc chmod 565
2.change to octal mode --xr-xr-- to abc chmod 154
3.change to octal mode rw----rwx to abc chmod 607
4.change to octal mode ---r-x--- to abc chmod 050

III
symbolic way
1.change r-xrw-r-x to rw--wxrwx to abc chmod u+w,u-x,g-r,g+x,o+w
2.change --xr-xr-- to rwxrwxrw- to abc chmod u+rw,g+w,o+w
3.change rw----rwx to --x----wx to abc chmod u-rw,u+x,o-r
4.change ---r-x--- to rwx-w-rwx to abc chmo u+rwx,g-rx,g+w,o+rwx

No comments:

Post a Comment