You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

误删libstdc++.so.6后无法通过APT重装该库的解决方法咨询

误删libstdc++.so.6后无法通过APT重装该库的解决方法咨询

Hey there, I feel your pain—you followed a tutorial to fix one issue, only to break something way more critical that locks you out of your usual package manager. Let’s work through some practical ways to get libstdc++.so.6 back up and running without relying on a broken apt-get.

方法一:手动下载并解压deb包恢复文件

Since apt-get is dead in the water right now, we’ll bypass it and grab the files directly:

  • First, confirm your OS version and architecture (you can check /etc/os-release with cat /etc/os-release—this command should still work even without libstdc++).
  • Grab the correct libstdc++6 .deb package for your system. Use another internet-connected machine to download it from your distro’s official package repository (make sure to pick the exact version matching your OS). Transfer the .deb file to your broken machine via USB, SSH (if that’s still working), or any other method.
  • Once you have the .deb file, extract its contents:
    1. Run ar x libstdc++6_*.deb—this will create three files: data.tar.xz, control.tar.xz, and debian-binary.
    2. Extract the actual system files with tar xf data.tar.xz. This will generate a directory structure matching your system.
    3. Navigate to the extracted lib directory and copy the files to your system’s library folder:
      cp ./usr/lib/x86_64-linux-gnu/libstdc++.so.6* /lib/x86_64-linux-gnu/
      
      The * ensures you copy both the soft link (libstdc++.so.6) and the actual underlying library file (like libstdc++.so.6.0.30).
  • Run ldconfig to update the system’s dynamic library cache, then test if apt-get works again. Once it’s back, run apt-get install --reinstall libstdc++6 to make sure all files are properly set up.

方法二:从同版本正常系统拷贝文件

If you have another machine running the exact same OS version and architecture:

  • On the working machine, copy the entire set of libstdc++ files from /lib/x86_64-linux-gnu/—look for libstdc++.so.6 and its corresponding versioned file (e.g., libstdc++.so.6.0.28).
  • Transfer these files to your broken machine’s /lib/x86_64-linux-gnu/ directory.
  • Fix the file permissions if needed:
    chown root:root /lib/x86_64-linux-gnu/libstdc++.so.6*
    chmod 644 /lib/x86_64-linux-gnu/libstdc++.so.6*
    
  • Run ldconfig to refresh the cache, then try apt-get again.

方法三:使用静态链接的包管理工具

Some distros offer statically linked versions of package managers that don’t depend on system dynamic libraries:

  • Check if your system has apt-static installed (run apt-static --version to test). If it does, simply run:
    apt-static install --reinstall libstdc++6
    
  • If apt-static isn’t available, you might look for a statically compiled dpkg binary (though this is less common).

A quick heads-up: Make sure you’re running all these commands as root (use sudo if you can, or switch to root with su).

备注:内容来源于stack exchange,提问作者silverhash

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.17 08:40:28