rmdir Command Purpose Removes a directory. Syntax rmdir [ -p ] Directory ... Description The rmdir command removes the directory, specified by the Directory parameter, from the system. The directory must be emp- ty before you can remove it, and you must have write permission in its parent directory. Use the ls -al command to check whether the directory is empty. Flags -p Removes all directories along the path name specified by the Directory parameter. Parent directories must be empty and the user must have write permission in the parent directories before they can be removed. Exit Status This command returns the following exit values: 0 Each directory entry specified by a Directory operand was re- moved successfully. >0 An error occurred. Examples 1. To empty and remove a directory, enter: rm mydir/* mydir/.* rmdir mydir This removes the contents of mydir, then removes the empty direc- tory. The rm command displays an error message about trying to remove the directories . (dot) and .. (dot-dot), and then the rmdir command removes them. Note that rm mydir/* mydir/.* first removes files with names that do not begin with a dot, and then removes those with names that do begin with a dot. You may not realize that the directory con- tains file names that begin with a dot because the ls command does not normally list them unless you use the -a flag. 2. To remove the /home, /home/demo, and /home/demo/mydir direc- tories, enter: rmdir -p /home/demo/mydir This first removes the /mydir directory and then the /demo and /home directories in order. If a directory is not empty or does not have write permission when it is to be removed, the command terminates. Implementation Specifics This command is part of Base Operating System (BOS) Runtime. Files /usr/bin/rmdir Contains the rmdir command. Related Information Files Overview in AIX Version 3.2 System User's Guide: Base and Devices. Directory Overview in AIX Version 3.2 System Management Guide: Operating System and Devices. Understanding File and Directory Access Modes in AIX Version 3.2 System User's Guide: Base and Devices. The ls command, mkdir command, rm command. The rmdir subroutine, unlink subroutine.