Monday, 18 May 2015

umask command in unix

umask command in unix

What is umask?
It is a number which define the default permissions which are not given on a file or directory.

Calculation of Umask:
You can simply subtract the umask from the base permissions to determine the final permission for file as follows.

Suppose umask 000
It means User has 0, Group has 0 and other has also 0
It means folder permission
User permission is      7-0 =7 (Read, Write and Execute)
Group Permission is   7-0 =7 (Read, Write and Execute)
Other Permission is    7-0 =7 (Read, Write and Execute)


Suppose umask 002
It means User has 0, Group has 0 and other has 2
It means folder permission
User permission is     7-0 =7 (Read, Write and Execute)
Group Permission is   7-0 =7 (Read, Write and Execute)
Other Permission is    7-2 =5 (Read and Execute)


Suppose umask 022

It means User has 0, Group has 2 and other has 2
It means folder permission
User permission is      7-0 =7 (Read, Write and Execute)
Group Permission is   7-2 =5 (Read and Execute)
Other Permission is    7-2 =5 (Read and Execute)


Suppose umask 027

It means User has 0, Group has 2 and other has 2
It means folder permission
User permission is      7-0 =7 (Read, Write and Execute)
Group Permission is   7-2 =5 (Read and Execute)
Other Permission is    7-7 =0 (No permission)


UmaskUser permissionGroup permissionOthers permission
000allallall
002allallread & execute
022allread / executeread / execute
027allread / executeNo permission

How to find out the umask value?

$ umask
0022

How to change the Umask?

$ umask 002


Saturday, 16 May 2015

date_sunrise - Returns time of sunrise for a given day and location

mixed date_sunrise ( int $timestamp [, int $format = SUNFUNCS_RET_STRING [, float $latitude = ini_get("date.default_latitude") [, float $longitude = ini_get("date.default_longitude") [, float $zenith = ini_get("date.sunrise_zenith


Returns time of sunrise for a given day and location
date_sunrise() returns the sunrise time for a given day (specified as a timestamp) and location.

<?php/* calculate the sunrise time for Lisbon, Portugal
Latitude: 38.4 North
Longitude: 9 West
Zenith ~= 90
offset: +1 GMT
*/

echo date("D M d Y"). ', sunrise time : ' .date_sunrise(time(), SUNFUNCS_RET_STRING38.4, -9901);
?>

SUNFUNCS_RET_STRING returns the result as string 16:46 SUNFUNCS_RET_DOUBLE returns the result as float 16.78243132 SUNFUNCS_RET_TIMESTAMP returns the result as integer (timestamp) 1095034606