The inode of the file defines the size of the file, the characteristics of all files, and so on. Each file and directory has its own unique inode number. But why use Inode to delete files, instead of using the usual RM-RF command? The reason is if you accidentally create files and directories that contain special characters, such as with a. * ^ file name, it will be difficult to delete. Here we will introduce: 1 How to find the file and directory of the Inode;2) with the search command, delete specific inode files; 3 other useful ways to remove stubborn files.
* How to find the inode of the file?
With stat or Ls-il. The LS command with the-I parameter refers to the inode that displays the file.
* How do I delete this file after I find the inode?
Find. -inum [inode number]-exec rm-i {}/;
1 The following is a complete experiment to create a file with special characters:
$ cd/tmp
$ touch "/+xy/+/8″
$ ls
2 attempt to delete with rm command
$ rm/+xy/+/8
3) Find the inode number of this file
$ ls-il
342137-rw-r–r–1 tw tw 0 2008-11-20 08:57/+xy/+/8
4) 342137 is the number of inode we are looking for. Remove it with the Find command below
$ find. -inum 342137-exec Rm-i {}/;
For example, your system has "2008/11/20″ this file, with RM is not deleted." Linux does not allow you to create this file, but it is available under Windows. So find with the use of the inode is here.
Here are some other useful removal tips:
* You can try to delete the file by quoting the filename. such as "–help" file, can be deleted with RM "–help"
* You can also delete files with unlink. Unlink. The unlink command calls the unlink function to delete a specific file
* Use Mtools to remove illegal files created under Windows. This method is most useful when the find command is invalid with the inode. A folder specifically designed to deal with Autorun.inf virus creation.
You can also xargs with RM to bulk delete files in different locations: The full path to the deleted file is written to a text file, such as the file.txt content as follows:
File1
/tmp/file2.txt
~/data.txt
Then run the following command to delete the files listed in file.txt
$ xargs RM