How to solve the problem that files cannot be deleted in linux

08-01-2023

The knowledge points of how to solve the problem of how to solve the problem of how to delete files in Linux are not well understood by most people, so the editor summarizes the following content for you. The content is detailed, the steps are clear, and it has certain reference value. I hope you can read it. This article can be rewarding. Let's take a look at 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 information. The basic format of this command is:

[root@localhost ~]# rm[option] file or directory

Note that the rm command is a broken It is a permanent 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 will not be restored. Therefore, especially when using the rm command to delete When cataloging, be cautious.

If the rm command does not add any options, the default execution is rm -i file name, that is, it will ask whether to delete a file before deleting it. For example:

[root@localhost ~]# touch cangls [root@localhost ~]# rm cangls rm: delete plain empty file "cangls"?y #Will ask whether to delete before deleting

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 we actually delete files, we will choose to force delete. For example:

[root@localhost ~]# mkdir -p /test/lm/movie/jp # Recreate the test directory [root@localhost ~]# rm -rf /test #Force Delete

After adding the force function, deletion will become very simple, but it should be noted that data cannot be recovered after forced deletion, unless relying on third-party data recovery tools, but data recovery is also difficult Recover complete data.

The above is the content of this article about how to solve the problem that files cannot be deleted in linux. I believe everyone has a certain understanding. For knowledge content, please pay attention to the Yisu cloud industry information channel.

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us