Home >Operation and Maintenance >Linux Operation and Maintenance >How to solve the problem that files cannot be deleted in Linux
rm is the delete command, which can permanently delete the specified file or directory in the file system. When using the rm command to delete a file or directory, the system will not generate any prompt message. The basic format of this command is:
[root@localhost ~]# rm[options] file or directory
Note that the rm command is a destructive command , because the rm command will permanently delete the file or directory, which means that if the file or directory is not backed up, once it is deleted using the rm command, it cannot be recovered. Therefore, especially when using the rm command to delete a directory, Be cautious.
If no options are added to the rm command, the default execution is "rm -i file name", which means that before deleting a file, it will ask whether to delete it. For example:
[root@localhost ~]# touch cangls [root@localhost ~]# rm cangls rm:是否删除普通空文件"cangls"?y #删除前会询问是否删除
If there are tens of thousands of subdirectories or subfiles in the directory to be deleted, then ordinary rm deletion requires at least tens of thousands of confirmations. Therefore, when actually deleting files, we will choose to force delete. For example:
[root@localhost ~]# mkdir -p /test/lm/movie/jp #重新建立测试目录 [root@localhost ~]# rm -rf /test #强制删除
After adding the force function, deletion will become very simple, but it should be noted that data cannot be recovered after force deletion unless relying on third-party data recovery tools, but data recovery is also difficult to recover complete data.
The above is the detailed content of How to solve the problem that files cannot be deleted in Linux. For more information, please follow other related articles on the PHP Chinese website!