One, use the rm command
rm [options] name...
rm: Refers to the delete command
options: Parameter selection such as:
-i : Ask for confirmation one by one before deleting.
-f : Even if the original file attribute is set to read-only, it will be deleted directly without confirming one by one, and it will be deleted forcibly
-r : delete the files in the directory and below one by one, which involves recursive processing, and the subdirectories under the directory will all have sound effects
name: Refers to the file name or file directory
2. Example:
If /home/test/ has: text.txt (txt file), homework (homework directory)
A. Input: rm test.txt
Prompt: rm: Do you want to delete the general file "test.txt"? Then enter: y (Enter). delete
B. Input: rm homework
Tip: rm: Cannot delete directory "homework": is a directory
C. Input: rm -r homework
Prompt: rm: Do you want to delete the directory "homework"? Then enter: y (Enter). delete
D. Deleting all files and directories in the current directory is a very dangerous operation . Command behavior:
rm -r * // * means all files in the current directory
E. Delete all files and directories in the current directory, and delete them directly, without confirming the command line as:
rm -rf file name or directory to be deleted
F. Delete the file name test.txt and enter:
rm -rf test.txt
G. Delete the directory test, regardless of whether there are subdirectories or files in the directory, delete them directly:
rm -rf test/ // will delete the text.txt file in the text directory and the homework directory file
3. Warm reminder:
Before deleting the files, make a backup of the necessary files . In the actual combat process, it is best to understand the meaning of the execution commands and deepen the understanding of knowledge.
Learning document reference: https://www.runoob.com/linux/linux-comm-rm.html