In Linux/Unix, you can use the rmdir
or rm
command to remove a directory. Here’s how to do it:
- Open a terminal window.
- Navigate to the parent directory of the directory you want to remove.
- Type the following command to remove an empty directory using the
rmdir
command:
rmdir directory_name
Replace “directory_name” with the name of the directory you want to remove. This command will only work if the directory is empty.
- If the directory is not empty, you can use the
rm
command with the-r
(recursive) option to remove the directory and all its contents:
rm -r directory_name
Again, replace “directory_name” with the name of the directory you want to remove. This command will remove the directory and all its contents, so be careful when using it.
- If you want to be prompted for confirmation before each file is deleted, you can use the
-i
(interactive) option:
rm -ri directory_name
This will prompt you to confirm the deletion of each file in the directory before it is deleted.
Note that the rmdir
and rm
commands are powerful and can permanently delete files and directories, so use them with caution. Make sure you are in the correct directory and are deleting the correct files before executing the command.