Ubuntu误删除/usr/lib
就是误删除啦… 手太快了..
打sudo都打不了..
找一个Ubuntu对应版本的LiveCD引导
把原硬盘挂上来
cd /media/blahblah/
sudo mount --bind /sys sys/
sudo mount --bind /proc proc/
sudo mount --bind /dev dev/
sudo mount --bind /dev/pts dev/pts/
sudo chroot .
配置一下/etc/resolv.conf
然后重新安装所有包
apt install --reinstall $(dpkg --get-selections | grep -w 'install$' | awk '{ print $1 }')
或者只装涉及到/usr/lib
的
v=$(dpkg -S /usr/lib)
v=${v%: *}
# start bashism: varexp-replace-global
apt-get install --reinstall ${v//,}
遇到 Couldn't configure pre-depend perl-base:amd64 for debconf:amd64, probably a dependency cycle.
v=${v//perl-base}
apt-get install --reinstall ${v//,}
Bash的//
语法参考: https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion
感谢Mingye Wang和Mingcong Bai