Skip to main content

Home/ Web Development, Design & Programming/ Group items tagged manpages

Rss Feed Group items tagged

Herb Tucker

Linux Knowledge Base and Tutorial - 0 views

  • The UMASK value masks out the bits. The permissions that each position in the UMASK masks out are the same as the file permissions themselves. So, the left-most position masks out the owner permission, the middle position the group, and the right most masks out all others. If we have UMASK=007, the permissions for owner and group are not touched. However, for others, we have the value 7, which is obtained by setting all bits. Because this is a mask, all bits are unset. (The way I remember this is that the bits are inverted. Where it is set in the UMASK, it will be unset in the permissions, and vice versa.)
  • The problem many people have is that the umask command does not force permissions, but rather limits them
  • Therefore, setting the UMASK=007 does not force creation of executable programs, unless the program creating the file does itself).
  • ...6 more annotations...
  • - - regular file c - character device b - block device d - directory p - named pipe l - symbolic link
  • Lets look at a more complicated example. Assume we have UMASK=047. If our program creates a file with permissions 777, then our UMASK does nothing to the first digit, but masks out the 4 from the second digit, giving us 3. Then, because the last digit of the UMASK is 7, this masks out everything, so the permissions here are 0. As a result, the permissions for the file are 730. However, if the program creates the file with permissions 666, the resulting permissions are 620. The easy way to figure out the effects of the UMASK are to subtract the UMASK from the default permissions that the program sets. (Note that all negative values become 0.)
  • You can change it anytime using the umask command. The syntax is simply umask <new_umask>
  • Here the <new_umask> can either be the numeric value (e.g., 007) or symbolic. For example, to set the umask to 047 using the symbolic notation, we have umask u=,g=r,o=rwx
  • Where "new_owner" is the name of the user account we want to sent the owner of the file to, and "filename" is the file we want to change. In addition, you can use chown to change not only the owner, but the group of the file as well. This has the general syntax: chown new_owner.new:group filename
  • Another useful trick is the ability to set the owner and group to the same ones as another file. This is done with the --reference= option, which sets to the name of the file you are referencing. If you want to change just the group, you can use the chgrp command, which has the same basic syntax as chown. Not that both chgrp and chmod can also take the --reference= option. Further, all three of these commands take the -R option, which recursively changes the permissions, owner or group.
1 - 2 of 2
Showing 20 items per page