Ubuntu下 /usr/lib/* 内容恢复
source link: https://droidyue.com/blog/2021/07/29/ubuntu-recovery-usr-lib-files/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Ubuntu下 /usr/lib/* 内容恢复
Jul 29th, 2021
有一次处理 Ruby 的版本问题,删除了/usr/lib/ruby
文件夹,然后导致了ruby 出现各种问题。
那么怎么解决呢,重做系统,其实大可不必。在 Ubuntu 下使用这个方法即可。
raw_pkgs = `dpkg --get-selections`.split("\n")
need_reinstall = []
path="/usr/lib/ruby"
raw_pkgs.each do |x|
pkg = x.split(" ")[0]
if `dpkg -L #{pkg}`.include? path
puts "-> #{pkg} has files in #{path}"
need_reinstall << pkg
end
end
puts "\nYou need to reinstall #{need_reinstall.size} packages:"
puts "\tsudo apt-get install --reinstall " + need_reinstall.join(" ")
上面的内容保存成ruby脚本或者使用irb
后复制粘贴执行即可。
最后会得到一个sudo apt-get install --reinstall xxxxxx
的内容。 然后在终端 执行得到的输出内容即可。
Posted by androidyue Jul 29th, 2021APT, Linux, Ruby, Shell, Ubuntu
Related Issues not found
Please contact @droidyuecom to initialize the comment
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK