Low Orbit Flux Logo 2 D

Linux How To Delete All Files In A Directory

Deleting all files in a directory, like most things, is pretty easy on Linux.

To delete all files in a directory just run the following. Note that this is not recursive and does not delete the directory itself.

rm dir1/*

If you want to delete all files and sub directories within our directory you can use the following command.

rm -rf dir1/*

If you also want to delete the directory itself you can just specify the directory like this.

rm -rf dir1

That’s it. You should also check out our other article here Linux How to Delete a Directory That is Not Empty.