~/CyberRef$


rm

rm, short for remove, is used to permanently delete files and directories.

Tip: sudo rm -rf / will remove pretty much everything from the root of your file system. There are countless jokes about this online.


Removing a File

Removing a file is a simple task:

rm myFile.txt

The above command would delete the file.

Remove a Directory

You may mkdir myDirectory to create a new directory, but what if you don't want it anymore? You would remove it with:

rm -rf myDirectory

This would delete the given directory, as well as anything inside of it (including other neseted directories and their files). The -r argument recursively removes files, and the -f argument forces deletion (remove -f if you do not want to force deletion).

Confirm Before Deleting

Lastly, you may request confirmation before deleting by adding the -i argument:

rm -i myFile.txt

References

https://www.geeksforgeeks.org/linux-unix/rm-command-linux-examples/

https://itsfoss.com/sudo-rm-rf/