# rm - [Command Function](#section181141523142613) - [Syntax](#section8800926132619) - [Parameter Description](#section15476229152617) - [Usage](#section10578163215262) - [Example](#section18548133511263) - [Output](#section1565323814265) ## Command Function This command is used to delete a file or folder. ## Syntax rm \[_-r_\] \[_dirname / filename_\] ## Parameter Description **Table 1** Parameters

Parameter

Description

Value Range

-r

Deletes a directory. This parameter is optional. It is required if a directory is to be deleted.

N/A

dirname/filename

Indicates the name of the file or directory to be deleted. The value can be a path.

N/A

## Usage - The **rm** command deletes only one file or directory at a time. - The **rm -r** command can be used to delete a non-empty directory. ## Example Example: 1. Enter **rm log1.txt**. 2. Enter **rm -r sd**. ## Output **Figure 1** Deleting the **log1.txt** file ![](figure/deleting-the-log1-txt-file.png "deleting-the-log1-txt-file") **Figure 2** Deleting the **sd** directory ![](figure/deleting-the-sd-directory.png "deleting-the-sd-directory")