Linuxexit code > 0

rm: cannot remove directory: Directory not empty

$rm: cannot remove 'my_folder': Directory not empty

Analysis

You tried to remove a directory using rmdir or rm without the recursive flag, but it contains files.

Common Triggers

  • Using rmdir on a populated folder.
  • Using rm without -r.

Debug Checks

  • $List contents: ls -a <folder>.

Resolution

1
Use recursive remove: rm -rf <folder> (CAREFUL!).