Using umask to set permissions

The chmod command allows you to alter permissions on a file by file basis. The umask command allows you to do automatically when you create any file or directory. Every one has a default umask setting set up either by the system administrator or their .profile.

Umask allows you to specify the permissions od all files created after issue the umask command. Instead of dealing with individual file permissions, you can determain permissions for all futures files with a single command, Unfortunately, using umask to specify permissions is rather complicated, but it is made easier if you remember 2 ponts.

  1. Umask uses a numeric code for representing absolute permissions just as chmode does. Example: 777 means read, write and execute permission for user, group and others, 777 (rwxrwxrwx)
  2. you specify the permissions you want by telling umask what to substract from full permission value
  • Example: $umask 022

the above command gives all new files in this session will be given permission of rwxr-xr-x

  • Example: to make sure that no one other than your self can read, write, or execute your files, you can run the umask command at the beginning of your login session by putting the following line in your .profile file

$umask 007

i.e. The above command same as chmod 700 or chmod go-rwx, but umask applies to all files you create in your current login session after you issue the umask command.

Related Posts

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by k2schools
%d bloggers like this: