Linux Delete Folder Recursively Command

http‮/:s‬/www.lautturi.com
Linux Delete Folder Recursively Command

To delete a folder and all its contents recursively using the command line in Linux, you can use the rm command with the -f option to force the deletion of the files and the -r option to delete the files recursively:

$ rm -rf /path/to/folder

This will delete the /path/to/folder folder, including any subdirectories and their contents.

Note that this command will delete the folder and all its contents, including hidden files and files that are protected by special permissions. Be careful when using this command, as it cannot be undone and there is no way to recover the deleted files.

You can also use the find command with the -delete option to delete a folder and all its contents recursively:

$ find /path/to/folder -delete

This will find the /path/to/folder folder and all its contents and delete them.

Alternatively, you can use the rm command with the -i option to interactively delete the files, which will prompt you to confirm each file before it is deleted:

$ rm -ir /path/to/folder

This can be useful if you want to delete some, but not all, of the files in the folder.

These are just a few examples of how to delete a folder and all its contents recursively using the command line in Linux. The specific steps may vary depending on the distribution and version of Linux that you are using. You can refer to the documentation for the rm and find commands for more information on how to use them.

Created Time:2017-10-29 22:08:53  Author:lautturi