Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

umask(3) [php man page]

UMASK(3)								 1								  UMASK(3)

umask - Changes the current umask

SYNOPSIS
int umask ([int $mask]) DESCRIPTION
umask(3) sets PHP's umask to $mask & 0777 and returns the old umask. When PHP is being used as a server module, the umask is restored when each request is finished. PARAMETERS
o $mask - The new umask. RETURN VALUES
umask(3) without arguments simply returns the current umask otherwise the old umask is returned. EXAMPLES
Example #1 umask(3) example <?php $old = umask(0); chmod("/path/some_dir/some_file.txt", 0755); umask($old); // Checking if ($old != umask()) { die('An error occurred while changing back the umask'); } ?> NOTES
Note Avoid using this function in multithreaded webservers. It is better to change the file permissions with chmod(3) after creating the file. Using umask(3) can lead to unexpected behavior of concurrently running scripts and the webserver itself because they all use the same umask. PHP Documentation Group UMASK(3)

Check Out this Related Man Page

umask(2)							   System Calls 							  umask(2)

NAME
umask - set and get file creation mask SYNOPSIS
#include <sys/types.h> #include <sys/stat.h> mode_t umask(mode_t cmask); DESCRIPTION
The umask() function sets the process's file mode creation mask to cmask and returns the previous value of the mask. Only the access per- mission bits of cmask and the file mode creation mask are used. The mask is inherited by child processes. See intro(2) for more information on masks. RETURN VALUES
The previous value of the file mode creation mask is returned. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mkdir(1), sh(1), intro(2), chmod(2), creat(2), mknod(2), open(2), stat.h(3HEAD), attributes(5), standards(5) SunOS 5.10 28 Dec 1996 umask(2)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Perl Uploading Files

Using perl 5.8.0, Linux 2.4.20-30.9, RedHat 9.0. We have many .cgi's that allow privileged users to upload files to the server through a web browser. We've had these .cgi's for years and have never had any problems with them. Recently the files being uploaded are sometimes being given 600... (16 Replies)
Discussion started by: sstevens
16 Replies

2. UNIX for Advanced & Expert Users

Changing default permissions -without "umask"-...

Hi! My question is this: Is it possible to change the default permissions in UNIX (666 for files and 777 for directories)?. I am not talking about using the command "umask". I mean, with the command "umask" you can modify permissions from a default permissions x. Is it possible to make... (4 Replies)
Discussion started by: chicoGuapo
4 Replies

3. Shell Programming and Scripting

umask with find

Hi, Will umask work with find command ? I was trying to do find /newdir/apps/ -type d -name 'par' -print -exec umask 117 {} \; it returns with find: umask: Permission denied , I've checked permission of all the directores, they have 770. however, If I use the command find... (4 Replies)
Discussion started by: braindrain
4 Replies

4. Linux

help on umask

hai guys , i am having problem in getting the knowledge about umask. actually when i am putting command as umask some value is coming like 0022 by defalut. we can change its value also. but the main thing is thye file permisiion actually depends upon umask.how is it depends upon umask i want to... (6 Replies)
Discussion started by: suvendu4urs
6 Replies

5. UNIX for Dummies Questions & Answers

Unmask

Hi All, I'm a newbie to UNIX I'm learning AIX 5l Basics I'm unable to execute UNMASK command as mentioned. Could any one help me. (6 Replies)
Discussion started by: udayakumar
6 Replies

6. Solaris

umask

Due to urgent requirement to resolve some permission issues , I wish to set solaris 8 server so that any file written is on 777 . I guess need to set umask , how to set it ?? (7 Replies)
Discussion started by: falcon16
7 Replies

7. UNIX for Advanced & Expert Users

umask

Hi, Please, let me know how the umask is working? As per my understanding is aprt from subtracting from 666/777, logical gate operation is performing. Ex: If I set uname 011, it gave the permission like 666 for file. Request you to explain which gate's operation performed. $uname 011... (4 Replies)
Discussion started by: Nagapandi
4 Replies

8. UNIX for Dummies Questions & Answers

Monitoring umask execution

Good Day! I would like to ask, is there a way to find out the list of users or scripts that executed a umask command for a given time? Our server has been having issues about files being written with 000 access, and we need to find out if it's because someone or some code is playing around with... (4 Replies)
Discussion started by: mike_s_6
4 Replies

9. Shell Programming and Scripting

umask usage

Hi , i am facing small issue if anybody help appreciated. how can we give the default permissions as 777 for files by using umask command.. advance thank you.. regards rajesh:wall: (5 Replies)
Discussion started by: rajesh_pola
5 Replies

10. Tips and Tutorials

Unix File Permissions

Introduction I have seen some misinformation regarding Unix file permissions. I will try to set the record straight. Take a look at this example of some output from ls: $ ls -ld /usr/bin /usr/bin/cat drwxrwxr-x 3 root bin 8704 Sep 23 2004 /usr/bin -r-xr-xr-x 1 bin bin ... (6 Replies)
Discussion started by: Perderabo
6 Replies

11. Shell Programming and Scripting

How to change umask in shell scripting?

Hi, I have manually changed umak value by umask 0033 , After that i would like to change umask value into 0022 through shell scripting.. But it is changing while running the script. Once come out from script, it has not changed ... Ex: >umask 0033 >./1.sh 0022 >umask 0033 plz Any... (4 Replies)
Discussion started by: Mani_apr08
4 Replies

12. Solaris

How do files transferred via ftp or sftp gets thier permissions at destination?

We have umask defined under /etc/.login as 022. I have my user specific umask defined in /userhome/.login as 002. I understand ftp will not execute anything at destination, it simply transfers files. But it seem to be using 022 as umask for the files transferred. How does ftp knows what umask... (4 Replies)
Discussion started by: kchinnam
4 Replies

13. Red Hat

Changing system-wide for umask

Hi everybody, How can I change the default UMASK for non root users, e.g. I want the umask for every new created user will be 0044. Thanks (6 Replies)
Discussion started by: leo_ultra_leo
6 Replies

14. Shell Programming and Scripting

Cron and umask

Hi All, Please help to understand what I am missing. The default umask as in /etc/profile is 022. The Script running in Cron creates file with umask 026. The default User shell is ksh and the script runs on bash. How the Cron is creating the files with 026 umask, how to make it create files... (4 Replies)
Discussion started by: sathyaonnuix
4 Replies

15. Solaris

Umask permission

Hi All please help in this .. I have application user called: startsys umask already defined in the profile of application user as umask 033. Actually application creating files once the file getting create it created with different permission which is not the same of the defined... (8 Replies)
Discussion started by: AbuAliiiiiiiiii
8 Replies