Use the rm command of linux to remove files or directories
This article mainly introduces the use of linux rm command to remove files or directories, has a certain reference value, friends in need can refer to. Let's take a look at it with me.
Rm is a commonly used command, the function of this command is to delete one or more files or directories in a directory, it can also delete a directory and all files and subdirectories under it. For linked files, only the links are deleted, and the original files remain unchanged. Rm is also a dangerous command, and be especially careful when using it, especially for beginners, otherwise the entire system will be destroyed by this command (such as executing rm *-rf under / (root)). Therefore, before executing rm, we'd better confirm which directory you are in, what you want to delete, and keep a high level of sanity during the operation.
Syntax format: rm [parameters] [file]
Common parameters:
-f ignores files that do not exist, and there is no warning message-I will ask the user whether to do it before deletion-rmap R recursive deletion-v shows the detailed execution process of the instruction
Reference example
Ask for confirmation one by one before deletion:
[root@linuxcool ~] # rm-I test.txt.bz2 rm: remove regular file `test.txt.bz2'?
Delete directly without any hint:
[root@linuxcool] # rm-f test.txt.bz2
Recursively delete the directory and all files under the directory:
[root@linuxcool ~] # mkdir / data/log [root@linuxcool ~] # rm-rf / data/log
Delete all files in the current directory:
[root@linuxcool] # rm-rf *
Empty all files in the system (with caution):
[root@linuxcool] # rm-rf / * the above is to remove the details of a file or directory using linux's rm command. Have you learned anything after reading it? If you want to know more about it, welcome to the industry information!