Rmdir
Encyclopedia
rmdir is a command which will remove an empty directory
Directory (file systems)
In computing, a folder, directory, catalog, or drawer, is a virtual container originally derived from an earlier Object-oriented programming concept by the same name within a digital file system, in which groups of computer files and other folders can be kept and organized.A typical file system may...

 on a Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

, DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

, OS/2
OS/2
OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "Personal System/2 " line of second-generation personal...

 or Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

. In Unix, Linux, and MacOS, it is case sensitive, whereas DOS, OS/2 and Windows (95, 98, ME), you can type the characters in any combination of upper case and lower case letters, and rd/rmdir will recognize and remove that directory. Normal usage is straightforward where one types:


rmdir name_of_directory


Where name_of_directory corresponds with the name of the directory one wishes to delete. There are options to this command such as -p in Unix which removes parent directories if they are also empty.

For example:


rmdir -p foo/bar/baz


Will first remove baz/, then bar/ and finally foo/ thus removing the entire directory tree specified in the command argument.

rmdir will not remove a directory if it is not empty in UNIX. The correct way to remove a directory and all its contents recursively is with the rm
Rm (Unix)
rm is a basic UNIX command used to remove objects such as files, directories, device nodes, symbolic links, and so on from the filesystem...

 command. For example:


rm -r foo/bar/baz


The DOS equivalent of this command is deltree
Deltree
deltree is a command line command in Microsoft operating systems that deletes an entire subdirectory of files. It appeared in MS-DOS 6, and was retained throughout all Windows versions based upon MS-DOS, including Windows 95, Windows 98, and Windows Me...

, or in Microsoft Windows.


rd /s directory_name

NT Functionality

Windows based on the NT Kernel (XP, Vista, 7, Server 2003/2008) are case insensitive, just like their earlier predecessors, unless two files of the same name and different case exists. Then case sensitivity applies when selecting which file to use, or if the case does not match either file, one may be chosen by Windows.

Having two files named the same with different case sensitivity is allowed when either Windows Services for Unix is installed, or when the registry settings are set to allow this.

An example of the security risk is:

Using rd/rmdir and two directories with the same name and different case sensitivities exist, one of which contains valid data and/or programs, and the other contains incriminating materials and/or malware
Malware
Malware, short for malicious software, consists of programming that is designed to disrupt or deny operation, gather information that leads to loss of privacy or exploitation, or gain unauthorized access to system resources, or that otherwise exhibits abusive behavior...

. If rd/rmdir gets executed without regard to case sensitivity and Windows chooses the legitimate folder to delete, the only folder left is the undesired one. Windows then uses this folder instead of the previously legitimate one to execute programs, and you may be lead to believe it contains legitimate data.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK