Home >Operation and Maintenance >Linux Operation and Maintenance >How to delete files in Linux without prompting
In Linux, you can use the "rm -f file name" command to delete files without prompting. The rm command is used to delete a file or directory. When the parameter is set to "-f", even if the original file attributes Set as read-only, or delete directly without confirming one by one.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
How to delete files in Linux without prompting
The command to delete files and directories in Linux: rm command.
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 link is deleted, and the original files remain unchanged.
rm is a dangerous command. Be careful when using it, especially for novices, otherwise the entire system will be destroyed by this command (for example, execute rm * -rf in / (root directory)). Therefore, before we execute rm, it is best to confirm which directory we are in and what we want to delete, and keep a clear mind during the operation.
1. Command format:
rm [选项] 文件…
2. Command function:
Delete one or more files or directories in a directory. If the -r option is not used, rm will not delete the directory. If you use rm to delete a file, you can usually still restore the file to its original state.
3. Command parameters:
#-f, --force ignore files that do not exist and never give a prompt.
-i, --interactive Perform interactive deletion
-r, -R, --recursive Instruct rm to list the parameters All directories and subdirectories of are deleted recursively.
-v, --verbose Display the steps in detail
--help Display this help message and exit
--version Output version information and exit
4. Command example:
Example 1: To delete the file file, the system will first ask whether to delete it.
Command:
rm 文件名
Output:
[root@localhost test1]# ll
Total 4
-rw-r--r-- 1 root root 56 10-26 14:31 log.log root@localhost test1]# rm log.log rm:是否删除 一般文件 “log.log”? y root@localhost test1]# ll 总计 0[root@localhost test1]#
Description:
After entering the rm log.log command, the system It will ask whether to delete. After entering y, the file will be deleted. If you don't want to delete, the data will be n.
Example 2: Forcibly delete the file, the system will no longer prompt.
Command:
rm -f log1.log
Output:
[root@localhost test1]# ll
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to delete files in Linux without prompting. For more information, please follow other related articles on the PHP Chinese website!