Linux how to delete a directory
To delete a directory in Linux, you can use the rm
command with the -r
(recursive) option. Here’s how:
- Open the Terminal.
- Navigate to the parent directory of the directory you want to delete. For example, if you want to delete a directory named “example” located in your home directory, you would navigate to your home directory:
cd ~
- Delete the directory by running the following command:
rm -r directory-name
Replace “directory-name” with the name of the directory you want to delete. This will delete the directory and all of its contents, so be careful when using this command.
- Authenticate with your password if prompted.
Note that the rm
command is a powerful and potentially dangerous command, as it can permanently delete files and directories. Always double-check that you’re deleting the correct directory before running this command, and make sure you have a backup of any important files before deleting them.
Leave a Reply