umask 명령어 (AIX 5.3·6.1)

핵심 정리

  • 현재 셸 환경의 파일 생성 마스크를 보여 주거나 정합니다. 파일을 만들 때 마스크에 켜진 비트는 권한에서 빠집니다.
  • 3자리 8진수(umask 022)나 기호(umask a=rx,ug+w)로 정합니다. 기호 형식은 chmod와 같습니다.
  • 인수 없이 실행하면 현재 마스크를 8진수로, -S를 주면 기호(u=rwx,g=rwx,o=rx)로 보여 줍니다.
  • 하위 셸이나 별도 실행 환경에서 부르면 호출한 환경의 마스크는 바뀌지 않습니다. 보통 셸 내장 명령으로 씁니다.
  • -w처럼 하이픈으로 시작하는 마스크는 앞에 --를 붙입니다(umask -- -w).
  • AIX 5.3과 6.1 문서의 내용이 같습니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (두 버전 내용 같음)
원문 IBM Commands Reference — 5.3 Volume 5, 6.1 Volume 5
파일 /usr/bin/umask, /usr/bin/ksh(셸 내장 명령)
관련 명령어 chmod, ksh, csh, bsh

목적

파일 생성 마스크를 표시하거나 정합니다.

영어 원문

Displays or sets the file mode creation mask.

구문

text
umask [ -S ] [ Mask ]

설명

Mask 매개변수를 지정하지 않으면 umask 명령은 현재 셸 환경의 파일 모드 생성 마스크를 표준 출력에 표시합니다. 3자리 8진수나 기호 코드로 Mask를 지정하면 현재 셸 실행 환경의 파일 생성 마스크를 정합니다. 파일 생성 마스크에 켜진 비트는, 응용 프로그램이나 명령이 파일을 만들 때 요청한 권한에서 해당 비트를 지우는 데 쓰입니다.

기호 코드와 숫자 코드로 권한을 정하는 방법은 chmod 명령에서 설명합니다.

-S 플래그는 기호로 출력합니다. 지정하지 않으면 기본 출력 형식은 8진수입니다.

/usr/bin/umask 명령을 하위 셸이나 별도의 명령 실행 환경에서 부르면, 호출한 환경의 파일 모드 생성 마스크에는 영향을 주지 않습니다. 다음 예가 그런 경우입니다.

bash
(umask 002)
nohup umask ...
find . -exec umask ... \;
영어 원문

If the Mask parameter is not specified, the umask command displays to standard output the file mode creation mask of the current shell environment. If you specify the Mask parameter using a three-digit octal number or symbolic code, the umask command sets the file creation mask of the current shell execution environment. The bits set in the file creation mask are used to clear the corresponding bits requested by an application or command when creating a file.

The chmod command describes how to use the symbolic and numeric codes to set permissions.

The -S flag produces symbolic output. If the flag is not specified, the default output format is octal.

If the /usr/bin/umask command is called in a subshell or separate command execution environment, it does not affect the file mode creation mask of the caller's environment. This would be the case in the following example: (umask 002) nohup umask ... find . -exec umask ... \;

플래그

플래그 설명
-S 기호로 출력합니다.
영어 원문
  • -S — Produces symbolic output.

종료 상태

값 뜻
0 파일 모드 생성 마스크를 잘 바꿨거나, Mask 매개변수를 주지 않았습니다.
0보다 큼 오류가 났습니다.
영어 원문

The following exit values are returned:

  • 0 — The file mode creation mask was successfully changed, or no Mask parameter was supplied.
  • >0 — An error occurred.

예제

  1. 이후에 만드는 파일의 S_IWOTH 비트(다른 사용자 쓰기)가 지워지도록 마스크를 정합니다. 다음 둘 중 하나를 입력합니다.
bash
umask a=rx,ug+w
umask 002

마스크를 정한 뒤 현재 값을 확인하면 02가 나옵니다.

bash
umask
  1. 기호로 출력합니다. u=rwx,g=rwx,o=rx가 나옵니다.
bash
umask -S
  1. 숫자 출력이든 기호 출력이든 다음 umask 실행의 Mask 매개변수로 쓸 수 있습니다. 마스크가 예제 2처럼 정해져 있을 때, 이후에 만드는 파일의 S_IWGRP와 S_IWOTH 비트가 지워지도록 정합니다.
bash
umask g-w
  1. 이후에 만드는 파일의 쓰기 비트가 모두 지워지도록 정합니다.
bash
umask -- -w

참고: -r, -w, -x 같은 Mask 값(하이픈으로 시작하는 모든 값)은 옵션으로 해석되지 않도록 앞에 --(하이픈 두 개, 사이에 빈칸 없음)를 붙여야 합니다.

영어 원문
  1. To set the mode mask so that subsequently created files have their S_IWOTH bit cleared, enter either: umask a=rx,ug+w

OR umask 002

After setting the mode mask, display the current values of the mode mask by entering: umask

The screen displays the following value: 02

  1. To produce symbolic output, enter: umask -S

The screen displays the following values: u=rwx,g=rwx,o=rx

  1. Either numeric or symbol output can be used as the Mask parameter to a subsequent invocation of the umask command. Assume the mode mask is set as shown in example 2. To set the mode mask so that subsequently created files have their S_IWGRP and S_IWOTH bits cleared, enter: umask g-w

  2. To set the mode mask so that subsequently created files have all their write bits cleared, enter: umask -- -w

Note: The -r, -w, and -x Mask parameter values (or anything beginning with a hyphen) must be preceded by — (double hyphen, no space between) to keep it from being interpreted as an option.

파일

파일 설명
/usr/bin/ksh Korn 셸의 umask 내장 명령이 들어 있습니다.
/usr/bin/umask umask 명령이 들어 있습니다.

관련 명령어: bsh, chmod, csh, ksh

영어 원문
  • /usr/bin/ksh — Contains the Korn shell umask built-in command.
  • /usr/bin/umask — Contains the umask command.

Related information:

  • bsh command
  • chmod command
  • csh command
  • ksh command

리눅스(GNU)와 다른 점

리눅스의 umask도 bash 내장 명령이며 -S와 8진수·기호 형식을 똑같이 씁니다. 차이는 셸의 기본값과 설정 위치입니다. AIX는 /etc/security/user의 umask 속성(기본 022)으로 사용자별 기본값을 정하는 경우가 많습니다.