MKDIR — Make a directory

Format

MKDIR 'directory_name'  MODE(directory_permission_bits) STICKY|NOSTICKY

Description

You can use the MKDIR command to create a directory in the file system.

Parameters

directory_name
Specifies the name of the directory to be created. The name can be a relative path name or an absolute path name. You must enclose it in single quotation marks. A relative path name is relative to the working directory of the TSO/E session (usually the HOME directory). Therefore, you should usually specify an absolute path name. The name can be up to 1023 characters long. The name is case-sensitive; the system stores each character in the case entered.

All directories in the path name prior to the specified directory must already exist. If the specified directory already exists, no new directory is created.

MODE(directory_permission_bits)
Specifies the directory permission bits as three octal numbers, from 0 to 7, separated by commas or blanks. The octal values represent read (r), write (w), and search (x) access for: user, group, and other.

User permission is the permission given to the directory owner. Group permission is the permission given to the group the owner is a member of. Other permission is the permission given to any other user.

The mode for a directory created by MKDIR is determined by the mode itself and applying a umask to it.

The access indicated by each of the numbers 0–7 is:
0
No access
1
Search (x) access
2
Write-only (w) access
3
Write and search (wx) access
4
Read-only (r) access
5
Read and search (rx) access
6
Read and write (rw) access
7
Read, write, and search (rwx) access
The default permissions set when a directory is created are 755, representing:
7
User: read, write, and search permission.
5
Group: read and search permission.
5
Other: read and search permission.
STICKY
Specifies that the sticky bit is to be set on for a directory so a user cannot remove or rename a file in the directory unless one or more of these conditions are true:
  • The user owns the file
  • The user owns the directory
  • The user has superuser authority
NOSTICKY
Specifies that the sticky bit is to be set off in the directory. NOSTICKY is the default.

Return codes

0
Processing successful.
12
Processing unsuccessful. An error message has been issued.

Examples

  1. You want to create a directory using an absolute path name giving read, write, and search access to the directory owner and no access to the group and other classes. The new directory name is to be /tmp/bin. The directory /tmp already exists. You enter:
    MKDIR '/tmp/bin' MODE(7,0,0)
  2. You want to create a new directory under the working directory of your TSO/E session; therefore you can specify a relative path name. You want to name the new directory u2, and to set it up with the default permissions (755). You enter:
    MKDIR 'u2'