Table of Contents
The rm command is used to delete files or folders in Linux. Using the rm command is quite simple, this article will talk about it. It can be very simple but when used be careful. Why is that? I will say in the next part of the article.
Use the rm command
The rm command structure is as simple as:
rm [OPTION] item ...This item, you can understand it is a file or a directory, can also be many files or folders.
Normally, when you type rm to delete a file or folder, there will be a confirmation prompt before the deletion. You can use the -f option to skip asking for confirmation before deleting.
Options are supported
The rm command supports a number of options as image below.

You can type below command to show all the options of rm command:
rm --helpUsually the two most commonly used options are -f and -r. Use -f to ignore the deletion before deleting and use -r if you want to delete a directory containing content (not an empty directory).

You can see the difference in the example image above. When using the -f option, the rm command will skip asking you if you are sure to delete the file. And when you want to delete a non-empty directory, you must use the -r option otherwise it will not be deleted.
Be careful when using the rm command
You know, in Linux, you can use wildcards. With rm as well, you can delete multiple files at the same time through the wildcard. For example when you type the command below:
rm -f *.logThat means you will delete all the files that end in .log in the current directory.
Read more: Move and rename in Linux with mv command.
But if you type wrong, just a space in front of .log then you will have big trouble. As follows:
rm -f [space] *.logThis will delete all the files in the current directory and notify you that there is no .log file at all.
The most dangerous joke. The following command is widely used to make jokes with newcomers to Linux. This command will completely destroy your operating system. Never run that command.
rm -f /*Conclusion
This tutorial shows you how to use the rm command, which is quite simple. Besides, you have to be extremely careful when using the rm command because once you delete the data, it will be very difficult to restore as it was before.
(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).