dpkg-maintscript-helper:basename:符号链接层数过多

dpkg-maintscript-helper:basename:符号链接层数过多

我每次运行 apt-get 命令时都会出现这个错误,我不知道是什么原因造成的,但我尝试了所有与此相关的解决方案,但仍然没有希望

root@vmi575272:/# sudo apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  debconf
Suggested packages:
  debconf-doc debconf-utils libterm-readline-gnu-perl libgtk3-perl libnet-ldap-perl debconf-kde-helper
Recommended packages:
  debconf-i18n
The following packages will be REMOVED:
  unattended-upgrades
The following packages will be upgraded:
  debconf
1 upgraded, 0 newly installed, 1 to remove and 845 not upgraded.
9 not fully installed or removed.
Need to get 0 B/144 kB of archives.
After this operation, 309 kB disk space will be freed.
Do you want to continue? [Y/n] Y
Preconfiguring packages ...
(Reading database ... 119035 files and directories currently installed.)
Removing unattended-upgrades (1.11.2) ...
/usr/bin/dpkg-maintscript-helper: 649: /usr/bin/dpkg-maintscript-helper: basename: Too many levels of symbolic links
dpkg: error processing package unattended-upgrades (--remove):
 installed unattended-upgrades package post-removal script subprocess returned error exit status 127
Errors were encountered while processing:
 unattended-upgrades
E: Sub-process /usr/bin/dpkg returned an error code (1)

以下是可能有帮助的输出

root@vmi575272:/# dpkg -S $(find -L /usr/bin -type l)
find: ‘/usr/bin/rpm’: Too many levels of symbolic links
find: ‘/usr/bin/rpmquery’: Too many levels of symbolic links
find: File system loop detected; ‘/usr/bin/X11’ is part of the same file system loop as ‘/usr/bin’.
find: ‘/usr/bin/basename’: Too many levels of symbolic links
find: ‘/usr/bin/rpmverify’: Too many levels of symbolic links
find: ‘/usr/bin/awk’: Too many levels of symbolic links

root@vmi575272:/# ls -ld / /usr /usr/ /usr/bin /usr/bin/ /usr/bin/X11 /usr/bin/X11/ /usr/bin/python
drwxr-xr-x 23 root root  4096 Sep 22 12:16 /
drwxr-xr-x 14 root root  4096 Apr 24  2021 /usr
drwxr-xr-x 14 root root  4096 Apr 24  2021 /usr/
drwxr-xr-x  2 root root 36864 Sep 12 14:55 /usr/bin
drwxr-xr-x  2 root root 36864 Sep 12 14:55 /usr/bin/
lrwxrwxrwx  1 root root    18 Sep 12 14:55 /usr/bin/python -> /usr/bin/python3.4
lrwxrwxrwx  1 root root     1 May  3  2017 /usr/bin/X11 -> .
drwxr-xr-x  2 root root 36864 Sep 12 14:55 /usr/bin/X11/

root@vmi575272:/# stat / /usr /usr/ /usr/bin /usr/bin/ /usr/bin/X11 /usr/bin/X11/ /usr/bin/python
  File: /
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 802h/2050d      Inode: 2           Links: 23
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-10-11 15:41:41.547415955 +0200
Modify: 2022-09-22 12:16:04.369547625 +0200
Change: 2022-09-22 12:16:04.369547625 +0200
 Birth: -
  File: /usr
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 802h/2050d      Inode: 30670849    Links: 14
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-10-11 10:09:25.893927643 +0200
Modify: 2021-04-24 12:00:26.071463323 +0200
Change: 2021-04-24 12:00:26.071463323 +0200
 Birth: -
  File: /usr/
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 802h/2050d      Inode: 30670849    Links: 14
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-10-11 10:09:25.893927643 +0200
Modify: 2021-04-24 12:00:26.071463323 +0200
Change: 2021-04-24 12:00:26.071463323 +0200
 Birth: -
  File: /usr/bin
  Size: 36864           Blocks: 80         IO Block: 4096   directory
Device: 802h/2050d      Inode: 30670850    Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-10-11 15:45:30.985976735 +0200
Modify: 2022-09-12 14:55:40.661784931 +0200
Change: 2022-09-12 14:55:40.661784931 +0200
 Birth: -
  File: /usr/bin/
  Size: 36864           Blocks: 80         IO Block: 4096   directory
Device: 802h/2050d      Inode: 30670850    Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-10-11 15:45:30.985976735 +0200
Modify: 2022-09-12 14:55:40.661784931 +0200
Change: 2022-09-12 14:55:40.661784931 +0200
 Birth: -
  File: /usr/bin/X11 -> .
  Size: 1               Blocks: 0          IO Block: 4096   symbolic link
Device: 802h/2050d      Inode: 30681403    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-10-11 15:45:31.301974781 +0200
Modify: 2017-05-03 11:38:16.000000000 +0200
Change: 2021-04-30 00:24:41.712813306 +0200
 Birth: -
  File: /usr/bin/X11/
  Size: 36864           Blocks: 80         IO Block: 4096   directory
Device: 802h/2050d      Inode: 30670850    Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-10-11 15:45:30.985976735 +0200
Modify: 2022-09-12 14:55:40.661784931 +0200
Change: 2022-09-12 14:55:40.661784931 +0200
 Birth: -
  File: /usr/bin/python -> /usr/bin/python3.4
  Size: 18              Blocks: 0          IO Block: 4096   symbolic link
Device: 802h/2050d      Inode: 30677150    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-10-11 15:45:31.485973650 +0200
Modify: 2022-09-12 14:55:40.661784931 +0200
Change: 2022-09-12 14:55:40.661784931 +0200
 Birth: -

答案1

你有一个符号链接指向上级目录,这是一个循环。

您可以检查以ls -ld / /usr /usr/ /usr/bin /usr/bin/ /usr/bin/X11 /usr/bin/X11/ /usr/bin/python查看罪魁祸首在哪里。

更改ls -ldstat&lstat以获取更多调试点数。

问题识别:

通过此数据,我们可以看到,在您的情况下,/ur/bin/X11循环指向自身。
这使得所有访问都循环进行,如下所示:
/ur/bin/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11

解决方案 :

我们可以通过(1)删除(2)指向其他东西来打破循环,从而摆脱循环。

(1)删除:
执行rm /usr/bin/X11rm -f /usr/bin/X11

(2)指向其他东西来打破循环:
执行mkdir /usr/bin/X12,然后ln -s /usr/bin/X12 /usr/bin/X11

不管怎样,我们都会解决问题,apt-get 命令也会通过。
如果需要,我们可以稍后重新安装 X11。

相关内容