# 1

Hi,

I was trying to understand how to calculate umask value but couldnt get the right way to calculate it. can some one please give me a small formula or easy method to do it?

Thanks,
Waseem
 ahmedwaseem2000 View Public Profile for ahmedwaseem2000 Find all posts by ahmedwaseem2000
# 2
The permissions you see when you ls -l a file are derived from a 4 digit octal number. Ignoring the first digit for the moment (setuid,setgid and the sicky bit) we have 3 octal digits these digits represent the rights of, in order, owner, group and world to the resource. since 8 is the 3rd power of 2 we can represent 3 states with each octal digit (since 4+2+1=7) depending on which values are set (this is a bitmask ie based on powers of 2, handy to manipulate with bitwise operations)

The umask defines the permissions that are NOT available to each user group.
thus a umask of 027 means that owner has all rights, group has read and execute rights and everyone else has no rights.

Last edited by Scrutinizer; 06-01-2012 at 09:55 AM..
 Skrynesaver View Public Profile for Skrynesaver Find all posts by Skrynesaver
# 3
Thanks for the reply. still I find it difficult to understand. do you have any standard steps or formula to derive it?
 ahmedwaseem2000 View Public Profile for ahmedwaseem2000 Find all posts by ahmedwaseem2000
# 4
1. What permissions do you want to assign to owner, group and world by default
2. Add the index above (1, 2 or 4) of all other permissions together and put in that position in the umask
That's it.
 Skrynesaver View Public Profile for Skrynesaver Find all posts by Skrynesaver
# 5
Quote:
Originally Posted by ahmedwaseem2000
Thanks for the reply. still I find it difficult to understand. do you have any standard steps or formula to derive it?
It's nothing but an ordinary, boolean AND. Convert the octal numbers into bits, AND the permissions with the (reversed) mask, and there you have it.

Last edited by Corona688; 06-01-2012 at 02:16 PM..
 Corona688 View Public Profile for Corona688 Visit Corona688's homepage! Find all posts by Corona688

Difficulty: Medium
The Western Electric Model 500 telephone uses tone dialing to dial phone numbers.
True or False?

Calculate average from a given set of keys and values

Hello, I am writing a script which expects as its input a hash with student names as the keys and marks as the values. The script then returns array of average marks for student scored 60-70, 70-80, and over 90. Output expected 50-70 1 70-90 3 over 90 0 The test script so far...

Calculate percent using values in 2 files

Trying to use file1 which is the actual counts in \$2 associated with each \$1 entry. The total of each \$1 is in file2 with the total in \$3. So when there is a match between \$1 in file1 with \$1 in file2, then the % is calculated using the \$2 value of file1 and \$3 value of file2. Thank you :). ...

How to calculate avg values of csv file using shell scripting .?

hi all i have a reporting work and i want it to be automated using shell scripting kindly let me know how can i make that possibe . eg data are :...

Calculate average of top n% of values - UNIX

Hey guys, I have several huge tab delimited files which look like this: a 1 20 a 3 15 a 5 10 b 2 15 b 6 10 c 3 23 what I am interested is to calculate the average of top n% of data in third column. So for example for this file the top 50% values are: 23 20 (Please note that it...

Transpose timestamp based on column values and calculate time difference

Hello Expert, I need to transpose Date-Timestamp based on same column values and calculate time difference. The input file would be as below and required output is mentioned in the bottom INPUT File ======== 08/23/2012 12:36:09 JOB_5340 08/23/2012 12:36:14 JOB_5340 08/23/2012...

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do...

Calculate difference between two successive values

Hi, I have a file containing timestamps (at micro-seconds granularity). It looks like the following: 06:49:42.383818 06:49:42.390190 06:49:42.392308 06:49:42.392712 06:49:42.393437 06:49:42.393960 06:49:42.402115 Now I need a sed/awk script to take the difference of two successive...

calculate logical layout values for hdd

Please advice me how to calculate logical layout values in hdd from below table. Physical Layout ----------------- Bytes per Sector : 512 Sectors per Track : 480-1272 Number of Heads : 4 Number of Disks : 2 Logical Layout --------------- Number of Heads : 16 Number of Sectors /...

How to calculate the percentage for the values in column

Hi, I am having the file which contains the following two columns. 518 _factorial 256 _main 73 _atol 52 ___do_global_ctors 170 ___main 52 ___do_g How can calculate the percentage of each value in the first column ? first need to get the sum of the first column and...

read from a file and calculate values for a specified field

hi guys im running into a problem here im trying to calculate a sum a values from a field for example a hava a file caled <filename> and it has \$3 fields, and i want toextract a group of values from field &1 and compute the sum of values from \$3 accordingly this is my code so far... awk...