7.4 Default File Permissions

   

What will be the permissions of a newly created file or directory? By default, all new files carry rw-rw-rw- and all new directories have rwxrwxrwx permission. We can control default file permissions with the umask command. The umask command sets the mask for new files. A mask is three digit octal number similar to the one we used to set file permission. It shows which permissions will be revoked when new files or directories are created. For example, if you set umask to value 022, the write permission for group and other users will be withheld for a new file. New default permissions for files will be rw-r--r-- , and for directories these will be rwxr-xr-x . See the following command sequence for the role of umask on new files.

 $  touch file1  $  ll file1  -rw-rw-rw-   1 boota   users     0 Sep  8 18:06 file1 $  umask 022  $  touch file2  $  ll file2  -rw-r--r--   1 boota   users     0 Sep  8 18:06 file2 $ 

This happened because the octal character 2 represents " w " in the symbolic mode. When this appears in the group and other places, it revokes " w " or write permission from both of these. Also note that we have used the touch command, which creates a zero- size file if the file does not already exist. The touch command changes file update time to the current time if the file already exists.

The current mask value is displayed with the umask command when used without any argument.

 $  umask  022 $ 

A new mask value can be set at any time. A better place for setting the mask value is the user startup file $HOME/.profile so that the value is set as soon as a user logs in.


   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net