How to delete a folder with contents on ubuntu cli
To delete a folder and its contents in Ubuntu 23.04 using the command line interface (CLI), you can use the rm
command with the -r
(recursive) option. Be very careful when using the rm
command, as it will permanently delete files and folders.
Here's the basic syntax:
rm -r /path/to/your/folder
Replace "/path/to/your/folder" with the actual path to the folder you want to delete.
For example, if you want to delete a folder named "myfolder" located in your home directory, you can use the following command:
rm -r ~/myfolder
Again, be cautious when using the rm -r
command, as it will not prompt you for confirmation, and the deletion is irreversible. Double-check the path to the folder before running the command to avoid accidental data loss.
If you want to confirm each file deletion, you can use the -i
option:
rm -ri /path/to/your/folder
This will prompt you for confirmation before deleting each file and subdirectory.
Always exercise caution when using the rm
command, especially with the -r
option, to avoid unintentional data loss.
No Comments