0

I am having this error each time I run an apt-get command, I dont know what caused this but I tried every solution I found related to this but still no hope

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)

here's an output that may help

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: -
Neji Soltani
  • 103
  • 4
  • 1
    You have a **Sym-link Pointing back to Higher Parent Directory** , which is a loop. You can check with `ls -ld / /usr /usr/ /usr/bin /usr/bin/ /usr/bin/X11 /usr/bin/X11/ /usr/bin/python` to check where the Culprit is. Change `ls -ld` to `stat` & `lstat` to get more Debug Points. – Prem Oct 12 '22 at 11:48
  • 1
    @Prem I have updated the post with the output of `ls` and `stat` commands, for `lstat` is said _command not found_ – Neji Soltani Oct 12 '22 at 12:03
  • 2
    Note: If you can copy and paste the terminal output please do so instead of posting screenshots. It makes it much easier to extract information from it. – Gerald Schneider Oct 12 '22 at 12:07
  • Hmm , `/usr/bin/X11` is Pointing to itself `.` : BAD ! You might have to Delete that & try your original Commands which should now work , unless there are more such Symlink Issues. – Prem Oct 12 '22 at 12:08
  • @Prem is it save to delete ? and how can I do it ? – Neji Soltani Oct 12 '22 at 12:13
  • It is **currently unusable** & hence **Deletion is not going to make new Issues & will get rid of Existing Issues** ! With that awareness , if you Decide to Delete it : you can Execute `rm /usr/bin/X11` or `rm -f /usr/bin/X11` : Later you can reinstall whatever you had in there. – Prem Oct 12 '22 at 12:21
  • @Prem I just found out that x11 is a loop itself when I open it I find an other x11 forlder with the same content, cant we just fix the looping issue ? – Neji Soltani Oct 12 '22 at 12:25
  • Eventually , what are **the actual Contents** of X11 ? If you can access that , you can `mv` that to new Directory X12 & Delete X11 & `mv X12 X11` : All this , only if you can access the Contents of X11. I think we can not access the Contents. – Prem Oct 12 '22 at 12:35
  • When trying to access `/usr/bin/X11` , you will only get a Pointer to itself , hence you will only get `/usr/bin/X11/X11/X11/X11/X11/X11/X11/X11/X11/` , with no way to get the actual Contents , which will be inaccessible. You can try `mkdir /usr/bin/X12` , then `ls -s /usr/bin/X12 /usr/bin/X11` , which is a way to get rid of the loop. – Prem Oct 12 '22 at 14:41

1 Answers1

0

You have a Sym-link Pointing back to Higher Parent Directory , which is a loop.

You can check with ls -ld / /usr /usr/ /usr/bin /usr/bin/ /usr/bin/X11 /usr/bin/X11/ /usr/bin/python to check where the Culprit is.

Change ls -ld to stat & lstat to get more Debug Points.

ISSUE IDENTIFICATION :

With this Data , we can see that , in your case , /ur/bin/X11 is Pointing to itself in a loop.
This makes all accesses go in circles like :
/ur/bin/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11

SOLUTION :

We can get rid of the loop by (1) Deletion (2) Pointing to something else to break the loop.

(1) Deletion :
Execute rm /usr/bin/X11 or rm -f /usr/bin/X11

(2) Pointing to something else to break the loop :
Execute mkdir /usr/bin/X12 , then ln -s /usr/bin/X12 /usr/bin/X11

Either way , we are getting rid of the Issue & the apt-get commands will go through.
When required, we can reinstall X11, if necessary later.

Prem
  • 578
  • 1
  • 5
  • 12