Delete files and folders

rm is a program for removing files and folders.

WARNING: Files and folders remove using rm are permanently ereased. Even if you are using an operating system with a Trash/Recycle Bin folder, rm does not make use of such things.

Delete file

Syntax

rm [filepath]

Example

rm readme.txt

Delete all files in current/working directory

WARNING: This is incredibly dangerous. You can unintentional delete data using this command.

rm *

Delete all files and folder in current/working directory

WARNING: This is incredibly dangerous. You can unintentional delete data using this command.

rm -r *

Delete files with a particular extension

Syntax

rm *.[extension]

Example

The command will delete all files with the.jpg extension.

rm *.jpg

Delete a directory and all its files and sub-directories.

Syntax

rm -r [filepath]

Example

rm -r /root/pages/