mkdir 명령어 (AIX 5.3·6.1)

핵심 정리

  • 디렉터리를 하나 이상 새로 만듭니다. 새 디렉터리에는 .과 .. 항목이 들어갑니다.
  • 부모 디렉터리에 쓰기 권한이 있어야 합니다.
  • -m Mode로 권한을 정합니다(chmod와 같은 기호·숫자 형식). 지정하지 않으면 umask가 기본 권한을 정합니다.
  • -p는 없는 중간 디렉터리까지 만들고, 이미 있는 디렉터리는 오류 없이 건너뜁니다.
  • 새 디렉터리의 소유자·그룹은 프로세스의 실효 사용자·그룹 ID이고, setgid 비트는 부모 디렉터리에서 물려받습니다.
  • 6.1에서 -e(암호화 상속을 켠 디렉터리 만들기)가 생겼습니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (6.1에서 -e 플래그와 보안 절이 더해짐)
원문 IBM Commands Reference — 5.3 Volume 3, 6.1 Volume 3
파일 /usr/bin/mkdir
관련 명령어 chmod, umask, rmdir

목적

새 디렉터리를 하나 이상 만듭니다.

영어 원문

Creates one or more new directories.

구문

text
mkdir [ -e ] [ -m Mode ] [ -p ] Directory ...

-e는 6.1 구문에만 있습니다.

설명

mkdir 명령은 Directory 매개변수로 지정한 새 디렉터리를 하나 이상 만듭니다. 새 디렉터리마다 표준 항목인 .(점)과 ..(점 두 개)가 들어 있습니다. 새 디렉터리의 권한은 -m Mode 플래그로 지정할 수 있습니다. mkdir 명령의 기본 모드는 umask 서브루틴으로 정할 수 있습니다.

새 디렉터리의 소유자 ID와 그룹 ID는 각각 프로세스의 실효 사용자 ID와 그룹 ID가 됩니다. setgid 비트 설정은 부모 디렉터리에서 물려받습니다. setgid 비트를 바꾸려면 -m Mode 플래그를 지정하거나, 디렉터리를 만든 뒤 chmod 명령을 실행합니다.

참고: 새 디렉터리를 만들려면 부모 디렉터리에 쓰기 권한이 있어야 합니다.

영어 원문

The mkdir command creates one or more new directories specified by the Directory parameter. Each new directory contains the standard entries . (dot) and .. (dot-dot). You can specify the permissions for the new directories with the -m Mode flag. You can use the umask subroutine to set the default mode for the mkdir command.

The owner-ID and group-ID of the new directories are set to the process's effective user-ID and group-ID, respectively. The setgid bit setting is inherited from the parent directory. To change the setgid bit, you can either specify the -m Mode flag or issue the chmod command after the creation of the directory.

Note: To make a new directory you must have write permission in the parent directory.

플래그

플래그 설명
-e 암호화 상속을 켠 디렉터리를 만듭니다. 6.1부터
-m Mode 새 디렉터리의 권한 비트를 Mode 변수의 값으로 정합니다. Mode에는 chmod 명령의 Mode 매개변수와 같은 값을 기호 형식이나 숫자 형식으로 씁니다. 기호 형식으로 지정하면 연산 문자 +(더하기)와 -(빼기)는 a=rwx를 기준으로 해석합니다. 즉 +는 기본 모드에 권한을 더하고 -는 기본 모드에서 권한을 뺍니다. 권한 비트와 형식은 chmod 명령을 참고합니다.
-p 경로 중간에 없는 디렉터리를 만듭니다. -p를 지정하지 않으면 새로 만들 디렉터리의 부모 디렉터리가 이미 있어야 합니다. 중간 디렉터리는 아래 명령을 자동으로 실행해 만듭니다. 이미 있는 디렉터리를 가리키는 Directory 매개변수는 오류 없이 무시합니다.

-p가 중간 디렉터리를 만들 때 실행하는 명령([-m Mode]는 처음 mkdir을 실행할 때 준 옵션):

text
mkdir -p -m $(umask -S),u+wx $(dirname Directory) && mkdir [-m Mode] Directory
영어 원문
  • -e — Creates directories with encryption inheritance.
  • -m Mode — Sets the permission bits for the newly-created directories to the value specified by the Mode variable. The Mode variable takes the same values as the Mode parameter for the chmod command, either in symbolic or numeric form. When you specify the -m flag using symbolic format, the op characters + (plus) and - (minus) are interpreted relative to the assumed permission setting a=rwx. The + adds permissions to the default mode, and the - deletes permissions from the default mode. Refer to the chmodcommand for a complete description of permission bits and formats.
  • -p — Creates missing intermediate path name directories. If the -p flag is not specified, the parent directory of each-newly created directory must already exist. Intermediate directories are created through the automatic invocation of the following mkdir commands: mkdir -p -m $(umask -S),u+wx $(dirname Directory) && mkdir [-m Mode] Directory where the [-m Mode] represents any option supplied with your original invocation of the mkdir command. The mkdir command ignores any Directory parameter that names an existing directory. No error is issued.

종료 상태

값 뜻
0 지정한 디렉터리를 모두 만들었거나, -p를 지정했고 지정한 디렉터리가 이제 모두 있습니다.
0보다 큼 오류가 났습니다.
영어 원문

This command returns the following exit values:

  • 0 — All the specified directories were created successfully, or the -p option was specified and all the specified directories now exist.
  • >0 — An error occurred.

보안

RBAC 사용자와 Trusted AIX 사용자는 주의하세요. 이 명령은 특권 작업을 할 수 있으며, 특권 작업은 특권 사용자만 할 수 있습니다. 이 명령에 걸린 특권과 권한(authorization) 목록은 lssecattr 명령이나 getcmdattr 하위 명령으로 봅니다. 이 절은 6.1 문서에만 있습니다.

영어 원문

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

예제

  1. 현재 작업 디렉터리에 Test라는 새 디렉터리를 만듭니다. 기본 권한으로 만들어집니다.
bash
mkdir Test
  1. 미리 만들어 둔 /home/demo/sub1 디렉터리에 권한이 rwxr-xr-x인 Test 디렉터리를 만듭니다.
bash
mkdir -m 755 /home/demo/sub1/Test
  1. /home/demo/sub2 디렉터리에 기본 권한으로 Test 디렉터리를 만듭니다. /home, /home/demo, /home/demo/sub2가 없으면 -p가 함께 만듭니다.
bash
mkdir -p /home/demo/sub2/Test
영어 원문
  1. To create a new directory called Test in the current working directory, enter: mkdir Test

The Test directory is created with default permissions.

  1. To create a new directory called Test with rwxr-xr-x permissions in the previously created /home/demo/sub1 directory, enter: mkdir -m 755 /home/demo/sub1/Test

  2. To create a new directory called Test with default permissions in the /home/demo/sub2 directory, enter: mkdir -p /home/demo/sub2/Test

The -p flag creates the /home, /home/demo, and /home/demo/sub2 directories if they do not already exist.

파일

파일 설명
/usr/bin/mkdir mkdir 명령이 들어 있습니다.

관련 명령어: chmod, umask

영어 원문
  • /usr/bin/mkdir — Contains the mkdir command.

Related information:

  • chmod command
  • mkdir command
  • umask command
  • File and directory access modes

리눅스(GNU)와 다른 점

항목 AIX 5.3·6.1 GNU mkdir
-e 암호화 상속 디렉터리(6.1) 없음
-p의 동작 중간 디렉터리를 umask에 u+wx를 더한 권한으로 만든다고 명시 같은 방식(POSIX)

AIX 5.3·6.1 문서에는 -v(만든 디렉터리 표시), -Z(SELinux 문맥) 같은 GNU 플래그가 없습니다.