How do I remove a full directory in Linux?

When attempting to remove a directory using a command such as the rmdir, you may receive a prompt such as "rmdir: 'dir': Directory not empty" and be unable to delete the directory.

To remove a directory that contains other files or directories, use the following command.

rm -r mydir

In the example above, you would replace "mydir" with the name of the directory you want to delete. For example, if the directory was named files, you would type rm -r files at the prompt.

Executing the above command would delete all files and directories in the directory named in the command. However, it would also present a prompt for approval to delete each of the files. If you don't want to receive a prompt for each file, use the following command instead.

rm -rf mydir

In the example above, the "mydir" directory, along with all files and directories in that directory, would be deleted with no prompt or message.

Additional information

Comments
Guest

I read that the operation of "mashing" on modern flash-drives and SSD is of little use, since the nature of the record is not clustered, but the entire surface is used randomly. And “scoring with zeroes” the same areas is impossible, which means that the mashing may not occur at all where it is needed.