Just as you can create a folder using mkdir , you can delete a folder using rmdir :

rmdir Linux Command

The folder you delete must be empty (like dir2 directory was empty)

You can also delete multiple folders at once:

rmdir dir2 dir3  # to remove two empty directories

Be careful as this command does not ask for confirmation and it will immediately remove anything you ask it to remove.

There is no bin when removing files from the command line, and recovering lost files can be hard


If directory is not empty then rmdir command will give error

To delete folders with files in them, we'll use the more generic rm command which deletes files and folders, using the -rf options:

rm -rf dir1

rm Useful options:

• -f (force): Forces the removal of files without prompting for confirmation, even if the files are write-protected.

• -r or -R (recursive): Removes directories and their contents recursively.

-i (interactive): Prompts for confirmation before each removal.

-v (verbose): Displays information about what is being done during the removal process.

Introduction To Docker: A Beginner’s Guide