AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 917655
Accepted
answerSeeker
answerSeeker
Asked: 2017-05-23 00:27:15 +0800 CST2017-05-23 00:27:15 +0800 CST 2017-05-23 00:27:15 +0800 CST

有没有办法手动检查哪些额外的包将被删除?

  • 772

例如,假设我尝试删除“libopenshot11”,我得到:

The following packages will be REMOVED:
  libopenshot11 openshot-qt python3-openshot

在不先运行 apt remove 的情况下如何找到它?

apt
  • 3 3 个回答
  • 808 Views

3 个回答

  • Voted
  1. Zanna
    2017-05-23T00:35:43+08:002017-05-23T00:35:43+08:00

    你可以使用--simulateor-s选项,它会告诉你当你运行一个命令而不实际做任何事情时 APT 会做什么,例如......

    $ sudo apt remove -s file
    Reading package lists... Done
    Building dependency tree        
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
      libfile-stripnondeterminism-perl libltdl-dev libmail-sendmail-perl libsys-hostname-long-perl po-debconf
    Use 'sudo apt autoremove' to remove them.
    The following packages will be REMOVED
      cracklib-runtime debhelper dh-autoreconf dh-strip-nondeterminism file gdebi gdebi-core libtool lintian ubuntu-standard
    0 to upgrade, 0 to newly install, 10 to remove and 0 not to upgrade.
    Remv cracklib-runtime [2.9.2-3]
    Remv dh-autoreconf [13] [debhelper:amd64 ]
    Remv debhelper [10.2.2ubuntu1] [dh-strip-nondeterminism:amd64 ]
    Remv dh-strip-nondeterminism [0.032-1]
    Remv gdebi [0.9.5.7+nmu1]
    Remv gdebi-core [0.9.5.7+nmu1]
    Remv ubuntu-standard [1.379]
    Remv file [1:5.29-3] [lintian:amd64 libtool:amd64 ]
    Remv libtool [2.4.6-2] [lintian:amd64 ]
    Remv lintian [2.5.50.1]
    

    我们可以看到删除file包将是一个非常糟糕的主意......

    • 19
  2. anon
    2017-05-23T00:36:40+08:002017-05-23T00:36:40+08:00

    -sor--simulate选项用于模拟任何APT任务而不实际运行它。

    从官方手册页:

     -s, --simulate, --just-print, --dry-run, --recon, --no-act
           No action; perform a simulation of events that would occur based on
           the current system state but do not actually change the system.
           Locking will be disabled (Debug::NoLocking) so the system state
           could change while apt-get is running. Simulations can also be
           executed by non-root users which might not have read access to all
           apt configuration distorting the simulation. A notice expressing
           this warning is also shown by default for non-root users
           (APT::Get::Show-User-Simulation-Note). Configuration Item:
           APT::Get::Simulate.
    
    • 13
  3. Best Answer
    muru
    2017-05-23T01:05:54+08:002017-05-23T01:05:54+08:00

    Python APT API可用于为此编写一个简短的脚本:

    #! /usr/bin/python3
    import sys
    from apt import cache
    
    c = cache.Cache()
    for pkg in sys.argv[1:]:
        c[pkg].mark_delete()   
    
    print('\n'.join(pkg.name for pkg in c.get_changes() if pkg.marked_delete))
    

    例子:

    $ apt-get remove -s bash | grep Remv  
    Remv winusb [1.0.11+saucy1]
    Remv gdm [3.18.3-0ubuntu2]
    Remv gdm3 [3.18.3-0ubuntu2]
    Remv bash [4.3-14ubuntu1.2] [inxi:amd64 lightdm:amd64 bash-completion:amd64 ]
    Remv bash-completion [1:2.1-4.2ubuntu1.1] [inxi:amd64 lightdm:amd64 ]
    Remv inxi [2.2.35-0ubuntu1] [lightdm:amd64 ]
    Remv lightdm [1.18.3-0ubuntu1.1]
    
    $ apt-cache rdepends bash --installed | sed '1,2d' | sort -u
      bash-completion
        bash:i386
      gdm3
      inxi
      lightdm
      winusb
    
    $ ./check.py bash                                             
    inxi
    winusb
    gdm
    gdm3
    bash
    lightdm
    bash-completion
    
    • 11

相关问题

  • 如何编写 shell 脚本来安装应用程序列表?

  • 如何查看存档中可用的软件包的所有版本?

  • 是否可以说出我安装的哪些软件包不在原版安装中?

  • 如何删除 PPA?

  • 使用 apt-get upgrade 时如何强制安装内核更新?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve