How to Remove Empty and Non-Empty Directories in Linux [Snippets]

Removing a directory in Linux is harder than you think, and it's not uncommon to get errors that look like this:

folder: Directory not empty
folder: is a directory

The confusion comes because rmdir cannot be used to delete a directory with files or folders inside of it.