---
name: "umask"
section: "2"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/umask/2"
---

# umask(2)

set file creation mode mask

## NAME

**umask** – set file creation mode mask

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<sys/stat.h\>**

*mode\_t*\

**umask**(*mode\_t numask*);

## DESCRIPTION

The **umask**() routine sets the process's file mode creation mask to *numask* and returns the previous value of the mask. The 9 low-order access permission bits of *numask* are used by system calls, including [open(2)](/open/2.md), [mkdir(2)](/mkdir/2.md), and [mkfifo(2)](/mkfifo/2.md), to turn off corresponding bits requested in file mode. (See [chmod(2)](/chmod/2.md)). This clearing allows each user to restrict the default access to his files.

The default mask value is S\_IWGRP\|S\_IWOTH (022, write access for the owner only). Child processes inherit the mask of the calling process.

## RETURN VALUES

The previous value of the file mode mask is returned by the call.

## ERRORS

The **umask**() system call is always successful.

## SEE ALSO

[chmod(2)](/chmod/2.md), [mkfifo(2)](/mkfifo/2.md), [mknod(2)](/mknod/2.md), [open(2)](/open/2.md)

## STANDARDS

The **umask**() system call is expected to conform to ISO/IEC 9945-1:1990 (“POSIX.1”).

## HISTORY

The **umask**() function appeared in Version 7 AT&T UNIX.
