ubuntu 删除容器内没用的包

  1. 删除多余 apt 包
    这些就是依赖的所有动态链接库,接着我们将这些包用 apt-mark 声明为“手工安装的包”,即可阻止 apt purge 的自动卸载。
    然后,我们再自动卸载其余没有用到的包即可。完整shell脚本如下:
    find /usr/local -type f -executable -exec ldd '{}' ';' \
     | awk '/=>/ { print $(NF-1) }' \
     | sort -u \
     | xargs -r dpkg-query --search \
     | cut -d: -f1 \
     | sort -u \
     | xargs -r apt-mark manual \
    ; \
    apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false;
    
    

    https://www.mianshigee.com/note/detail/20422lhk/

  2. 删除容器内 python2
    apt-get remove --auto-remove python2.7
    apt-get purge --auto-remove python2.7
    apt-get autoclea python2.7
    
    whereis python2  # 查看是否存在python2
    whereis python2 |xargs rm -frv  # 删除python2所有残余文件

    https://zhuanlan.zhihu.com/p/526332103

     

posted on 2023-03-02 17:06  闹不机米  阅读(97)  评论(0编辑  收藏  举报

导航