Logo

Directory Gone! Mastering the 'delete directory linux' command

Need to tidy up your Linux file system? Deleting directories is a fundamental skill. But tread carefully – deleting a directory removes everything inside, so double-check before you proceed! The primary command for deleting empty directories is `rmdir`. Simply type `rmdir directory_name` in your terminal. If the directory isn't empty, `rmdir` will throw an error.

For non-empty directories, you'll need the powerful `rm` command with the `-r` (recursive) flag. Use `rm -r directory_name`. This recursively deletes the directory and all its contents. **Warning:** This is permanent! Consider using the `-i` (interactive) flag, like this: `rm -ri directory_name`, which will prompt you to confirm each deletion. This provides an extra layer of safety. Choose the method that suits your needs and always double-check the directory name before pressing enter to avoid accidental data loss. Happy cleaning!

See all content
Top Picks

Subscribe now and never miss an update!

Subscribe to receive weekly news and the latest tech trends

Logo
1 345 657 876
nerdy-mind 2025. All rights reserved