CL Command Reference - RD

CL Command List > RD Reference

Description:

The Remove Directory (RD) command removes a specified directory from the system after all objects in the directory have been unlinked and the directory is no longer in use. If a directory to be removed contains objects, this command optionally unlinks all of the objects and then deletes the directory. If the user does not have the authority to unlink every object in the directory, only those objects for which the user has the authority are unlinked. When an object cannot be unlinked, the directory and all objects in the directory that cannot be unlinked are not removed.

This command is an alias for the Remove Directory (RMVDIR) command and can also be issued using the following alternative command names:
. RMDIR
. RMVDIR

Restrictions:

1. In the ¡åroot¡å (/),QOpenSys and user-defined file systems, the user must have object existence (*OBJEXIST) authority for the specified directory, and *OBJEXIST authority for every object in it. If the user does not have *OBJEXIST authority for one or more objects in the directory, those objects are not unlinked and the directory is not removed.

2. In the ¡åroot¡å (/),QOpenSys, and user-defined file systems, the user must have write, execute (*WX) authority to the parent directory.

3. In the QDLS file system, the user must have all (*ALL) authority to the directory and execute (*X) authority to its parent directory.

4. The user must have execute (*X) authority to the prefix directory.

5. See the iSeries Security Reference, SC41-5302 book for the authority requirements for other file systems.

6. A user cannot remove a directory within a ¡åroot¡å (/), QOpenSys, or user-defined file system directory that has the ¡årestricted rename and unlink¡å attribute set on (this attribute is equivalent to the S_ISVTX mode bit) unless one or more of the following are true:
a. The user is the owner of the directory to be removed.
b. The user is the owner of the parent directory of the directory to be removed.
c. The user has all object (*ALLOBJ) special authority.

7. A directory can not be removed if it is the current directory for a job.

8. This command cannot be used to delete reserved directories and libraries.

9. When an object is in use in QSYS.LIB, independent ASP QSYS.LIB, or QDLS, the object cannot be unlinked. When an object is in use in QOpenSys or the ¡åroot¡å (/) file system, the object is successfully unlinked, and the object is deleted when no longer in use.


Examples:

The alternative command name for RD is RMVDIR. The following examples use the alternative command name, but RD can be replaced directly for RMVDIR in all of them.

Example 1: Removing a Directory and the Objects in that Directory

RMVDIR DIR(¡¯W¡¯) RMVLNK(*YES)

This command removes directory W after all of its objects have been unlinked. If directory W contains objects and you have the authority to unlink all of those objects, all of the objects are unlinked and directory W is removed. If you do not have authority to unlink all of the objects, only those for which you have authority are unlinked and the directory is not removed.