使用 inode 删除文件

使用 inode 删除文件

如果文件名中有不可见的字符,尝试通过 inode 来删除文件是一个比较可靠的方式。首先,获取该文件的 inode 号,然后删除它:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[root@localhost ~]# ls -i
4297410740 ''$'\224\205''.'
4298885037 公共
2148249428 模板
4299610662 视频
2148249429 图片
6445137595 文档
1943336 下载
1943337 音乐
6445137594 桌面
4299610637 anaconda-ks.cfg
2148000115 gmail_install
4297410741 gmail_install.tar.gz
4298385159 initial-setup-ks.cfg
4297410742 'x'$'\265''zO31'$'\222''Y͚'$'\377''ᅢ'$'\351\326''M'$'\336''A'$'\327''k'$'\227\237\314''v6'
4297410738 ''$'\243\207''Z'
[root@localhost ~]# find /root -inum 4297410738 -exec rm -f {} \;
[root@localhost ~]# ll
总用量 373252
-rw-r--r-- 1 root root 0 1月 23 15:56 ''$'\224\205''.'
drwxr-xr-x. 2 root root 10 1月 21 22:11 公共
drwxr-xr-x. 2 root root 10 1月 21 22:11 模板
drwxr-xr-x. 2 root root 10 1月 21 22:11 视频
drwxr-xr-x. 2 root root 10 1月 21 22:11 图片
drwxr-xr-x. 2 root root 10 1月 21 22:11 文档
drwxr-xr-x. 2 root root 10 1月 21 22:11 下载
drwxr-xr-x. 2 root root 10 1月 21 22:11 音乐
drwxr-xr-x. 2 root root 10 1月 21 22:11 桌面
-rw-------. 1 root root 1505 1月 1 2000 anaconda-ks.cfg
drwxr-xr-x 7 root root 118 7月 19 2023 gmail_install
-rw-r--r-- 1 root root 382198252 1月 23 16:02 gmail_install.tar.gz
-rw-r--r--. 1 root root 1732 6月 22 2018 initial-setup-ks.cfg
-rw-r--r-- 1 root root 0 1月 23 15:56 'x'$'\265''zO31'$'\222''Y͚'$'\377''ᅢ'$'\351\326''M'$'\336''A'$'\327''k'$'\227\237\314''v6'
[root@localhost ~]# find /root -inum 4297410742 -exec rm -f {} \;
[root@localhost ~]# find /root -inum 4297410740 -exec rm -f {} \;
[root@localhost ~]# ll
总用量 373252
drwxr-xr-x. 2 root root 10 1月 21 22:11 公共
drwxr-xr-x. 2 root root 10 1月 21 22:11 模板
drwxr-xr-x. 2 root root 10 1月 21 22:11 视频
drwxr-xr-x. 2 root root 10 1月 21 22:11 图片
drwxr-xr-x. 2 root root 10 1月 21 22:11 文档
drwxr-xr-x. 2 root root 10 1月 21 22:11 下载
drwxr-xr-x. 2 root root 10 1月 21 22:11 音乐
drwxr-xr-x. 2 root root 10 1月 21 22:11 桌面
-rw-------. 1 root root 1505 1月 1 2000 anaconda-ks.cfg
drwxr-xr-x 7 root root 118 7月 19 2023 gmail_install
-rw-r--r-- 1 root root 382198252 1月 23 16:02 gmail_install.tar.gz
-rw-r--r--. 1 root root 1732 6月 22 2018 initial-setup-ks.cfg
[root@localhost ~]#

image-20250124144428383