How to delete folder recursively in linux

In Linux, you can delete a folder recursively using the rm command with the -r option. The -r option tells the rm command to delete the folder and its contents recursively.

Here is the syntax for deleting a folder recursively using the rm command:

rm -r [foldername]

For example, if you want to delete a folder named myfolder and all its contents, run the following command:

rm -r myfolder

Be careful when using the rm command with the -r option, as it can delete files and directories recursively without prompting for confirmation.

If you want to delete a folder and its contents interactively, you can use the -i option. The -i option prompts you before deleting each file or directory, giving you the chance to confirm the deletion.

Here is the syntax for deleting a folder and its contents interactively:

rm -ri [foldername]

For example, if you want to delete a folder named myfolder and all its contents interactively, run the following command:

rm -ri myfolder

When using the rm command with the -ri option, you will be prompted to confirm each file and directory deletion. Type y for yes or n for no to confirm or cancel each deletion.

In conclusion, deleting a folder recursively in Linux is easy using the rm command with the -r option. Be careful when using this command, and consider using the -i option if you want to delete the folder and its contents interactively.