Accidently renamed the ld-linux-aarch64.so.1
On my Ubuntu command line system, I accidentally renamed the /lib/ld-linux-aarch64.so.1
file.
This led to behavior that I cannot use any bash/dash/sh commands and cannot use mv
any more to revert the file name. There are not many commands that I can execute and passing /bin/bash
or /bin/dash
as command is also not working and keeps saying: -bash: /bin/dash: No such file or directory
, -bash: /bin/ls: No such file or directory
.
Is there any way to get out of this state and recover?
This is done on 20.04.2 LTS (Focal Fossa). On the grub menu, you press 'c' to bring up a grub>
prompt.
grub> linux /boot/vmlinuz
grub> initrd /boot/initrd.img
grub> boot
This will boot into an initramfs (busybox) shell:
(initramfs) mkdir /mnt
(initramfs) mount /dev/sda1 /mnt
(initramfs) cd /mnt/lib/x86_64-linux-gnu
(initramfs) ls ld-*
ld-renamed.so*
(initramfs) # Your ld.so version may differ
(initramfs) # (bionic 18.04 is ld-2.27.so)
(initramfs) cp -i -a ld-renamed.so ld-2.31.so
(initramfs) ln -s ld-2.31.so ld-linux-x86-64.so.2
(initramfs) ls -F ld-*
ld-linux-x86-64.so.2@ ld-2.31.so*