Removing Directories in Linux Without Deleting the Wrong Thing
Deleting a directory in Linux is easy; choosing the right command for what’s inside it takes a little more care. rmdir stops if anything remains. rm -r deletes a directory tree, so a typo or unexpected path can remove more than you intended. For an empty directory, use rmdir: rmdir dirname It removes the directory only if it is empty. Hidden files count as contents, so a directory that looks empty in a regular ls listing may still make rmdir fail.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in