How to delete a directory in the Linux terminal?
Tagged: linux
- AuthorPosts
- August 28, 2020 at 12:31 PM #3690Santhosh Kumar DKeymaster@santhosh
Learning how to delete a directory in the Linux terminal makes it easy to manage directories.
To delete an empty directory, you need to use the
rm -d
command followed by the name of the directory that you want to delete.rm -d directory
To delete a directory containing subdirectories and files, use the
rm -r
command followed by the name of the directory you want to delete.rm -r directory
And to delete multiple directories containing subdirectories and files, use the
rm -r
command followed by directory names separated by a space.rm -r directory1 directory2 directory3
Note: Please be careful when deleting files or directories, because once deleted, it is not easy to recover them.
Learn more Linux commands.
August 28, 2020 at 1:03 PM #3696Santhosh Kumar DKeymaster@santhoshIf a subdirectory or a file within the main directory is write-protected, you will be prompted to confirm the deletion.
To force delete a directory containing subdirectories and files without being prompted, you need to use the
rm -rf
command followed by the directory name.rm -rf directory
- AuthorPosts
- You must be logged in to reply to this topic.