z/OS UNIX System Services User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF

Creating a directory

z/OS UNIX System Services User's Guide

Using the shell: To create a new directory, enter:
mkdir pathname
For example, if Alice Smith is working in her home directory, smitha, and she wants to create a new directory, projecta, under her working directory, she would enter:
mkdir projecta
The default mode (read-write-execute permissions) for a directory created with mkdir is:
  • owner=rwx
  • group=rwx
  • other=rwx
For directories, execute permission means permission to search the directory. The octal representation of these permissions is 777 (7 for the owner permission bits, the group permission bits, and the other permission bits).

The new directory, projecta, is one level below her working directory. Figure 1 shows this relationship. If you do not specify an absolute path name for the directory to be created, the shell creates the new directory as a subdirectory of whatever your working directory is at the time you enter the command.

Figure 1. Creating a new directoryWhat the file system structure looks like when a new directory is created.

If you want to create a new directory that is not under your working directory, specify an absolute path name. Both directory names and file names can be up to 255 characters long. You may want to adopt some naming convention that allows you to distinguish between directory names and file names.

Your business may have adopted naming conventions for directories. For example, a typical convention is for each user to be assigned a directory based uniquely on the TSO/E user ID to make the name unique. Only that user would have write access to the directory. For information on how to change access permissions for a directory or file so that other users can read or write to it, see Handling security for your files.

Using TSO/E: To create a new directory, enter:
MKDIR 'directory_name' MODE(directory_permission_bits)
where directory_name specifies the path name of the directory to be created. The path name can be a full path name or a relative path name. Specify the name, which can be up to 1023 characters long, in single quotation marks. Specify MODE, the directory permission bits, in 3 octal characters; they can be separated by commas or blanks. The default mode (read-write-execute permission) is:
  • owner = rwx
  • group = r-x
  • other = r-x

The octal representation of these permissions is 755. (When MKDIR is used to create a directory, the default permission bits are different from when mkdir is used.) Here execute permission means permission to search the directory.

Example: To specify a directory with a full path name and mode 700, enter:
MKDIR '/u/smitha/umods' MODE(7,0,0)
It is best to use a full path name with the MKDIR command. When a relative path name is specified, MKDIR defines the directory in the user's home directory, regardless of the working directory. If user Alice Smith is in her home directory smitha and wants to create a directory with a relative path name and the default mode, she can enter:
MKDIR 'umods'
The directory umods is one level below her home directory, smitha. Its full path name is /u/smitha/umods.

Go to the previous page Go to the next page

Copyright IBM Corporation 1990, 2014