Linux rm Command
Using the “rm” linux command allows you to delete a file or a directory. Knowing the options will help you in the long run and might prevent you from removing your entire hard drive!
Check the rm
options:
-r Recursive. Deletes directories as well as files
-f Force remove without prompt.
-i Interactively delete each file. Useful if you want to check before you remove!
Some examples would be:
# force delete a directory
rm -rf some-directory
# interactive
rm -i some-file-not-sure-about
It might be useful to add in a trash
command that you can use which will
place items in a trash which is an extra step before the files or directories
are removed permanently:
# mac os
trash() { mv -fv "$@" ~/.Trash/ ; }
# linux
alias trash='mkdir -p "$HOME/.trash" && mv -b -t "$HOME/.trash"'
Read more about it the rm manual pages.