How to delete a directory and its contents using the rm command?
Published on Aug. 22, 2023, 12:17 p.m.
To delete a directory and its contents using the rm
command in Linux, you can use the following syntax:
rm -r directoryname
Where directoryname
is the name of the directory you want to delete. The -r
option tells rm
to delete the directory and its contents recursively.
For example, let’s say we have a directory named mydir
that we want to delete. We can use the following command:
rm -r mydir
This will delete the directory mydir
and all of its contents.
Note that the rm
command is a powerful tool that can permanently delete your files, so use it with caution. Make sure you are deleting the correct directory before running this command.