Synthird's blog

Deleting files and folders in the Linux terminal

Deleting files

To delete files, use the rm command:

rm file-name

Deleting folders

To delete folders, use the rmdir command:

rmdir folder-name

Keep in mind that rmdir only works if the folder is empty. It won't even work if the folder only has empty subfolders.

Deleting folders with files and/or subfolders inside

To delete a non-empty folder, use the -r flag in the rm command:

rm -r folder-name