How to remove a directory?

QuestionsQuestions4 SkillsProBasic Files OperationsAug, 21 2025
0142

To remove a directory, you can use the rm command with the -r (recursive) option. This allows you to delete the directory and all of its contents. Here’s the basic syntax:

rm -r directory-name

For example, to remove a directory named old_projects, you would run:

rm -r old_projects

Important Notes:

  • Be very careful with this command, as it will delete everything in the specified directory without asking for confirmation.
  • If the directory is empty, you can also use the rmdir command:
rmdir directory-name

This command will only work if the directory is empty.

0 Comments

no data
Be the first to share your comment!