delete directory linux 3 code example

Example 1: delete directory linux

rm -rf dir1

Example 2: remove directory from linux

rm -r filename

rm -rf filename

this command remove the directory and subdirectory forecefully

Example 3: remove directory linux

rm -rf /path/to/directory/*

Example 4: rm directory linux

To remove an empty directory, use either rmdir or rm -d followed by the directory name: 
rm -d dirname rmdir dirname.
To remove non-empty directories and all the files within them, use the rm command with the -r (recursive) option: 
rm -r dirname.

Tags:

Misc Example